/* ---------- Améliorations V1 : bandeau, accueil, outils du graphique, recherche ---------- */

.brand { color: inherit; text-decoration: none; border-radius: 8px; padding: 2px 6px; margin-left: -6px; transition: background .2s; }
.brand:hover { background: var(--panel-2); }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand .logo-img { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.layout { height: calc(100vh - 136px); }

/* Bandeau défilant */
.ticker {
  position: relative; overflow: hidden; height: 36px; border-bottom: 1px solid var(--border); background: var(--panel);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.ticker:empty { display: none; }
.tk-track { display: flex; align-items: center; width: max-content; height: 100%; animation: tk-scroll 60s linear infinite; }
.ticker:hover .tk-track { animation-play-state: paused; }
@keyframes tk-scroll { to { transform: translateX(-50%); } }
.tk-item {
  display: inline-flex; align-items: center; gap: 8px; height: 100%; padding: 0 18px; border: 0; border-radius: 0;
  background: transparent; color: var(--text); font-size: 13px; white-space: nowrap; cursor: pointer;
}
.tk-item:hover { background: var(--panel-2); }
.tk-name { color: var(--muted); }
.tk-sep { width: 40px; }

/* Accueil */
.home { display: flex; flex-direction: column; gap: 16px; }
.home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.home-head h2 { margin: 0 0 2px; font-size: 20px; }
.breadth { display: grid; gap: 4px; min-width: 240px; }
.breadth-bar { height: 8px; border-radius: 4px; background: rgba(239, 68, 68, .55); overflow: hidden; }
.breadth-bar .up-part { display: block; height: 100%; background: var(--up); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.mk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
.mk-card {
  position: relative; display: grid; gap: 2px; padding: 12px 12px 0; overflow: hidden; text-align: left;
  border-radius: 12px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); cursor: pointer;
  transition: transform .2s, border-color .2s, box-shadow .2s; animation: rise .35s ease-out both;
}
.mk-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0, 0, 0, .3); }
.mk-card.is-up:hover { border-color: rgba(34, 197, 94, .5); }
.mk-card.is-down:hover { border-color: rgba(239, 68, 68, .5); }
.mk-top { display: flex; align-items: center; min-width: 0; }
.mk-top .logo-wrap { width: 22px; height: 22px; border-radius: 6px; margin-right: 6px; }
.mk-name { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-price { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mk-change .pill { font-size: 12px; }
.spark { display: block; width: calc(100% + 24px); height: 40px; margin: 6px -12px 0; }
.spark-ref { stroke: rgba(138, 148, 168, .45); stroke-dasharray: 3 3; stroke-width: 1; vector-effect: non-scaling-stroke; }
.skeleton-card { min-height: 120px; background: linear-gradient(90deg, var(--panel-2) 25%, #1f2a40 50%, var(--panel-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }

.recents { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.recents .muted { margin-right: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 0; padding: 4px 10px 4px 4px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip .logo-wrap { width: 20px; height: 20px; border-radius: 50%; margin-right: 6px; }

.mv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px 24px; }
.mv-col h3 { display: flex; align-items: center; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 6px; }
.mkt-tag { padding: 1px 6px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--border); font-size: 10px; color: var(--text); letter-spacing: 0; }
.mv-list { list-style: none; margin: 0; padding: 0; }
.mv-list button {
  display: grid; grid-template-columns: auto minmax(0, 1fr) 70px auto auto; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; cursor: pointer;
  animation: rise .3s ease-out both; animation-delay: calc(var(--i, 0) * 30ms);
}
.mv-list button:hover { background: var(--panel-2); }
.mv-list .logo-wrap { width: 26px; height: 26px; margin-right: 0; }
.mv-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.mv-name b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv-bar { height: 4px; border-radius: 2px; background: var(--panel-2); overflow: hidden; }
.mv-bar span { display: block; height: 100%; border-radius: 2px; }
.mv-bar .up { background: var(--up); }
.mv-bar .down { background: var(--down); }
.mv-price { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }

/* En-tête : favori et partage */
.fav-btn, .share-btn {
  width: 28px; height: 28px; padding: 0; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer; transition: color .2s, background .2s;
}
.share-btn { font-size: 13px; }
.fav-btn:hover, .share-btn:hover { background: var(--panel-2); color: var(--text); }
.fav-btn.active { color: #fbbf24; }
.fav-btn.pop { animation: fav-pop .35s cubic-bezier(.2, .9, .3, 1.5); }
@keyframes fav-pop { 50% { transform: scale(1.45); } }

/* Barre d'outils du graphique */
.chart-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 8px; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); }
.seg button {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 7px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--border); color: var(--text); }
.seg.multi button.active { background: rgb(var(--accent-rgb) / .18); color: var(--text); }
.seg button i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; opacity: .5; }
.seg button.active i { opacity: 1; }
.icon-btn {
  margin-left: auto; width: 30px; height: 28px; padding: 0; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--muted); font-size: 15px; cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }

/* Légende au survol */
.chart-box { position: relative; }
.chart-legend {
  position: absolute; top: 4px; left: 6px; z-index: 3; display: flex; flex-wrap: wrap; gap: 4px 10px; max-width: calc(100% - 90px);
  padding: 4px 8px; border-radius: 6px; background: rgba(23, 18, 20, .78); font-size: 12px; pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.chart-legend:empty { display: none; }
.lg-date { color: var(--muted); }
.subchart { height: 130px; margin-top: 4px; border-top: 1px solid var(--border); }

/* Plein écran */
.chart-panel:fullscreen, .chart-panel.pseudo-fullscreen { display: flex; flex-direction: column; padding: 16px 20px; background: var(--bg); overflow: auto; }
.chart-panel.pseudo-fullscreen { position: fixed; inset: 0; z-index: 100; border-radius: 0; }
.chart-panel:fullscreen .chart-box, .chart-panel.pseudo-fullscreen .chart-box { flex: 1; min-height: 0; }
.chart-panel:fullscreen .chart, .chart-panel.pseudo-fullscreen .chart { height: 100%; min-height: 300px; }
.chart-panel:fullscreen .subchart, .chart-panel.pseudo-fullscreen .subchart { height: 22vh; }

/* Recherche */
.search-results { max-height: 420px; overflow-y: auto; padding: 4px; }
.search-results li {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
}
.search-results li.active, .search-results li[data-symbol]:hover { background: var(--panel-2); }
.search-results li.active { box-shadow: inset 2px 0 0 var(--accent); }
.search-results .logo-wrap { width: 26px; height: 26px; margin-right: 0; }
.search-results .sr-group { display: block; padding: 8px 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); cursor: default; }
.search-results .sr-group:hover { background: none; }
.sr-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sr-name { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-type { padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--border); }
.sr-type.t-etf { color: #60a5fa; border-color: rgba(96, 165, 250, .4); }
.sr-type.t-cryptocurrency { color: #fbbf24; border-color: rgba(251, 191, 36, .4); }
.sr-type.t-index { color: #a78bfa; border-color: rgba(167, 139, 250, .4); }
.sr-type.t-equity { color: #4ade80; border-color: rgba(74, 222, 128, .35); }
.sr-exch { font-size: 11px; }

/* Notification éphémère */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200; max-width: min(90vw, 480px); padding: 10px 16px; border-radius: 10px;
  background: #1f2a40; border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); font-size: 13px;
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .layout { height: auto; }
  .mv-list button { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .mv-bar { display: none; }
  .icon-btn { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .tk-track { animation: none; overflow-x: auto; }
  .mk-card, .mv-list button { animation: none; }
}

/* Un élément masqué reste masqué, même si sa classe définit un display (ex. .home en flex) */
[hidden] { display: none !important; }

/* Périodes intégrées à la barre du graphique */
.tb-break { flex-basis: 100%; height: 0; }
.seg.ranges { overflow-x: auto; scrollbar-width: none; }
.seg.ranges::-webkit-scrollbar { display: none; }
.seg.ranges button { padding: 5px 11px; font-size: 12.5px; white-space: nowrap; }
.seg.ranges button.active { background: var(--accent); color: var(--on-accent); box-shadow: 0 2px 10px rgb(var(--accent-rgb) / .35); }
.seg.ranges button.live .live-dot { width: 6px; height: 6px; margin-right: 2px; }
.seg.ranges button.live.active .live-dot { background: #fff; }
.chart-panel.is-loading .chart-box { opacity: .55; transition: opacity .2s; }

/* Barre du graphique sur une ligne : menus déroulants Indicateurs et Affichage, outils en icônes à droite */
.chart-toolbar { flex-wrap: wrap; gap: 6px; }
.tb-menu { position: relative; }
.tb-menu-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tb-menu-btn:hover, .tb-menu.open .tb-menu-btn { color: var(--text); border-color: var(--accent); }
.tb-menu-btn .ic { width: 15px; height: 15px; }
.tb-menu-btn .tb-chev { width: 13px; height: 13px; transition: transform .2s; }
.tb-menu.open .tb-chev { transform: rotate(180deg); }
.tb-count { min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 10.5px; line-height: 17px; text-align: center; }
.tb-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 250px; padding: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 14px 36px rgba(0, 0, 0, .35);
  animation: tb-pop .14s ease-out;
}
@keyframes tb-pop { from { opacity: 0; transform: translateY(-4px); } }
.tb-pop-title { margin: 8px 2px 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tb-pop-title:first-child { margin-top: 0; }
.tb-pop .seg { display: flex; width: 100%; }
.tb-pop .seg.multi { flex-direction: column; gap: 2px; background: transparent; border: 0; padding: 0; }
.tb-pop .seg.multi button { justify-content: flex-start; flex-wrap: wrap; padding: 7px 9px; font-size: 13px; text-align: left; }
.tb-pop .seg.multi button small { flex-basis: 100%; padding-left: 12px; font-size: 11px; font-weight: 400; color: var(--muted); }
.tb-pop .seg[data-group="toggles"] button small { padding-left: 0; }
.tb-pop .seg:not(.multi) button { flex: 1; justify-content: center; padding: 6px 8px; font-size: 12.5px; }
.tb-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.tb-tools .icon-btn { margin-left: 0; display: inline-flex; align-items: center; justify-content: center; }
.tb-tools .seg button { padding: 4px 7px; }
.tb-tools .seg .ic { width: 15px; height: 15px; }
