:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #17212c;
  --muted: #66727f;
  --line: #d9dfe7;
  --accent: #0f6e74;
  --accent-ink: #ffffff;
  --up: #157a4a;
  --down: #b8352b;
  --radius: 6px;
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
h1, h2 { margin: 0 0 .5rem; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; }
code { font-size: .9em; background: var(--bg); padding: .1em .3em; border-radius: 3px; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.error { color: var(--down); font-size: .9rem; }
.up { color: var(--up); }
.down { color: var(--down); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cur { font-size: .72em; color: var(--muted); }

/* Boutons */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; padding: .45rem .9rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--radius);
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.tiny { padding: .15rem .55rem; font-size: .95rem; line-height: 1.3; }
.btn.held { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--down); }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Formulaires */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
input { font: inherit; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); min-width: 0; }
input[readonly] { background: var(--bg); }

/* Connexion */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-card { background: var(--surface); padding: 2rem; border-radius: 10px; width: 100%; max-width: 360px; border: 1px solid var(--line); }
.login-card h1 { font-size: 1.8rem; }
.login-card .brand { display: block; font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.login-card .seg { display: flex; }
.login-card .seg button { flex: 1; }
.login-card form { display: grid; gap: .9rem; margin-top: 1.25rem; }

/* Barre du haut */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 800; font-size: 1.15rem; color: var(--accent); }
.tabs { display: flex; gap: .25rem; flex: 1; }
.tab { font: inherit; font-weight: 600; background: none; border: 0; padding: .45rem .8rem; border-radius: var(--radius); color: var(--muted); cursor: pointer; }
.tab.active { color: var(--ink); background: var(--bg); }
.user { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }

main { padding: 1rem; max-width: 1200px; margin: 0 auto; }
.panel { display: grid; gap: .9rem; }

/* Barre d'outils du marché */
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.toolbar input[type=search] { flex: 1 1 220px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button { font: inherit; font-weight: 600; border: 0; background: none; padding: .45rem .8rem; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent); color: #fff; }

/* Tableaux */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; font-weight: 700; color: var(--muted); background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th.sorted { color: var(--accent); }
th.sorted.asc::after { content: " ▲"; font-size: .6em; }
th.sorted.desc::after { content: " ▼"; font-size: .6em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr[data-sym] { cursor: pointer; }
tbody tr[data-sym]:hover { background: #f5f8fb; }
td.sym, .sym { font-weight: 700; white-space: nowrap; }
td.name { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.act { text-align: right; white-space: nowrap; }
td.act .btn + .btn { margin-left: .3rem; }
.empty { padding: 2rem; text-align: center; color: var(--muted); margin: 0; }

.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: .1rem .4rem; border-radius: 4px; background: var(--bg); color: var(--muted); vertical-align: middle; }
.badge.TSX { background: #e3f1ec; color: #1d6b4d; }
.badge.TSXV { background: #eaf3e6; color: #4b6b2a; }
.badge.US { background: #e6ecf7; color: #2c4a8a; }

.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; color: var(--muted); font-size: .9rem; }

/* Portefeuille */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.tot { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; }
.tot span { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; }
.tot b { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tot small { font-size: .75rem; font-weight: 600; }
.add-form { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; display: grid; gap: .75rem; }
.add-form .row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.add-form .row label { flex: 1 1 130px; }
.add-form .row label.grow { flex: 2 1 200px; }

/* Fiche */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(440px, 92vw); box-shadow: 0 20px 60px rgba(23,33,44,.25); }
dialog::backdrop { background: rgba(23,33,44,.4); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.dsym { font-size: 1.4rem; font-weight: 800; }
.detail-body { padding: 1rem 1.2rem; display: grid; gap: .4rem; }
.kv { display: flex; justify-content: space-between; gap: 1rem; font-size: .95rem; }
.kv span { color: var(--muted); }
.kv b { font-variant-numeric: tabular-nums; }
.kv.big b { font-size: 1.5rem; }
.detail-body .btn { margin-top: .6rem; justify-self: start; }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .topbar { gap: .75rem; padding: .5rem .75rem; }
  .user span { display: none; }
  main { padding: .6rem; }
  th, td { padding: .5rem .5rem; }
  td.name { max-width: 150px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===== Bloc 1b : vitrine ===== */
a.brand { text-decoration: none; }
.site { max-width: 1000px; margin: 0 auto; padding: 0 1.25rem 3rem; }
.site-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 0; gap: 1rem; }
.site-head nav { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.site-head nav a { text-decoration: none; color: var(--ink); font-weight: 600; padding: .45rem .7rem; }
.site-head nav a.btn { padding: .45rem .9rem; }
.hero { padding: 4rem 0 3rem; max-width: 640px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.05; letter-spacing: -.02em; }
.hero p { font-size: 1.1rem; color: var(--muted); line-height: 1.5; margin: 1rem 0 1.5rem; }
.cta { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.cta a { text-decoration: none; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; padding: 1rem 0 3rem; }
.feat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.2rem; }
.feat h3 { margin: 0 0 .4rem; font-size: 1rem; }
.feat p { margin: 0; color: var(--muted); line-height: 1.45; font-size: .95rem; }
.soon { font-size: .7rem; font-weight: 700; color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 0 .3rem; vertical-align: middle; }
.pricing h2 { font-size: 1.6rem; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; max-width: 900px; margin: 1rem 0; }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.4rem; }
.plan.featured { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.plan h3 { margin: 0; }
.price { font-size: 2rem; font-weight: 800; margin: .5rem 0; }
.price small { font-size: .9rem; font-weight: 600; color: var(--muted); }
.plan ul { margin: .5rem 0 0; padding-left: 1.1rem; color: var(--muted); line-height: 1.7; }
.site-foot { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: 1.5rem; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.site-foot a { color: var(--accent); }

/* ===== Bloc 1b : super-admin ===== */
.badge.SUPER { background: #f4e7c8; color: #7a5a10; }
.badge.st-trial { background: #e6ecf7; color: #2c4a8a; }
.badge.st-active { background: #e3f1ec; color: #1d6b4d; }
.badge.st-suspended { background: #f7e3e1; color: #9c2e26; }
select { font: inherit; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
td input[type=text], td input[type=number], td input:not([type]) { padding: .3rem .5rem; width: 100%; }
td input[type=checkbox] { width: 1.1rem; height: 1.1rem; }
.super .tabs { flex-wrap: wrap; }
.super .user a { text-decoration: none; }
.user a.btn { text-decoration: none; }

/* ===== Bloc 2 : radar ===== */
.chip { display: inline-block; font-size: .72rem; background: var(--bg); border-radius: 4px; padding: .1rem .4rem; margin: .1rem .25rem .1rem 0; color: var(--ink); white-space: nowrap; }
td.reasons { max-width: 360px; }
.scores { display: flex; gap: .5rem; margin: .5rem 0; }
.score { flex: 1; background: var(--bg); border-radius: 6px; padding: .5rem; text-align: center; }
.score span { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); }
.score b { font-size: 1.4rem; font-weight: 800; }
.spark { width: 100%; height: 70px; display: block; }
.why { margin: .2rem 0 .5rem; padding-left: 1.1rem; font-size: .85rem; line-height: 1.5; }
details summary { cursor: pointer; font-weight: 600; font-size: .9rem; margin-top: .4rem; }
.row-btns { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.detail-body .row-btns .btn { margin-top: 0; }
@media (max-width: 640px) { td.reasons { max-width: 180px; } .chip { white-space: normal; } }

/* ===== Bloc 3 : veille et alertes ===== */
.verdict { font-weight: 700; font-size: .85rem; }
.veille { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .75rem; }
.vcard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; cursor: pointer; }
.vcard p { margin: .4rem 0 0; font-size: .9rem; line-height: 1.45; }
.vhead { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.h3 { font-size: .95rem; margin: .8rem 0 .3rem; }
.news { margin: .3rem 0; padding-left: 1.1rem; font-size: .85rem; line-height: 1.4; }
.news li { margin-bottom: .4rem; }
.news a { color: var(--accent); }
.bell { position: relative; font-size: 1rem; }
.bell-n { position: absolute; top: -2px; right: -2px; background: var(--down); color: #fff; font-size: .65rem; font-weight: 700; border-radius: 10px; padding: 0 .35rem; min-width: 1.1rem; text-align: center; }
.alert { border-left: 3px solid var(--line); padding: .4rem .7rem; margin-bottom: .5rem; }
.alert.new { border-color: var(--accent); background: #f1f8f8; }
.alert.stop, .alert.baisse { border-color: var(--down); }
.alert.cible { border-color: var(--up); }
.alert p { margin: .3rem 0 0; white-space: pre-line; }
.prefs { border-top: 1px solid var(--line); }
label.inline { flex-direction: row; align-items: center; gap: .5rem; color: var(--ink); font-weight: 500; }

/* ===== Bloc 4 : accueil et plans ===== */
.tend { font-weight: 700; font-size: .85rem; white-space: nowrap; }
.plan-banner { background: #fff7e0; border: 1px solid #ecd9a0; border-radius: 8px; padding: .7rem 1rem; font-size: .9rem; }
.plan-banner a, .upsell a, .upsell-box a { color: var(--accent); font-weight: 600; }
.upsell, .upsell-box { background: #f1f8f8; border: 1px solid #cfe5e6; border-radius: 6px; padding: .6rem .9rem; margin: .5rem 0 0; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.pick { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .75rem .9rem; cursor: pointer; display: grid; gap: .25rem; }
.pick .vhead b { font-size: 1.3rem; font-weight: 800; }
#tab-accueil h2 { margin-top: .6rem; }
