/* ===== Panel : structure de page (connexion, barre du haut, colonnes) =====
   Même direction artistique que la carte des agents : aplats, angles légèrement arrondis,
   pas de bordure sur les cartes (seuls les séparateurs internes, très discrets).
   Transitions : fondus courts ; fenêtres et menus s'ouvrent avec un léger scale. */

:root {
  --Edge: #ecebe7;             /* séparateurs internes (lignes de liste, de tableau) */
  --Good: #2f7d4f;
  --Up: #2f8a5a;               /* graphiques : au-dessus de zéro */
  --Down: #c2414a;             /* graphiques : en dessous de zéro */
  --ChartBlue: #3b78ad;
  --Warn: #b07d12;
  --Fade: 160ms ease;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --Edge: #232323; --Good: #7db38a; --Up: #83d8ac; --Down: #eb888f; --ChartBlue: #8db6dd; --Warn: #e2b04a; }
}
:root[data-theme="dark"] { --Edge: #232323; --Good: #7db38a; --Up: #83d8ac; --Down: #eb888f; --ChartBlue: #8db6dd; --Warn: #e2b04a; }

/* La carte bloque le défilement (Theme.css) ; le panel est une page qui défile, en douceur */
html, body { height: auto; min-height: 100%; overflow: visible; }
html { scroll-behavior: smooth; scrollbar-gutter: stable; }   /* place de la barre réservée : rien ne se décale quand elle apparaît */
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.02em; }
.Muted { color: var(--Muted); }
.Small { font-size: 12px; }
.Nowrap { white-space: nowrap; }
.Num { text-align: right; font-variant-numeric: tabular-nums; }

/* Fondu sur tout ce qui réagit au survol ou au clic */
a, button, .Btn, .Input, .Tile, .Card, .Toast, .Search,
.Nav a, .Tabs button, .ViewSwitch button, .Picker button,
.ModelRow, .ActivityRow, .NotificationItem, .Suggestion, .NetworkLink,
.ComboButton, .ComboOption, .MonthCell, .MarkRead {
  transition: background-color var(--Fade), color var(--Fade), border-color var(--Fade), opacity var(--Fade), box-shadow var(--Fade), transform 140ms var(--Ease);
}

/* Éléments qui apparaissent / disparaissent en fondu (classe posée par Dom.Show / Dom.Hide) */
.Fadeable { opacity: 0; transition: opacity var(--Fade); }

/* Bloc qui change de taille (Dom.Morph) : la hauteur glisse, les éléments montent un à un */
.IsMorphing { overflow: hidden; transition: height 380ms var(--Ease); }
.IsGrowing { overflow: hidden; transition: height 320ms var(--Ease); }   /* Dom.Grow */
@keyframes Rise { from { opacity: 0; transform: translateY(8px); } }
.Rise { animation: Rise 360ms var(--Ease) backwards; animation-delay: calc(var(--I, 0) * 40ms); }
.Sink { opacity: 0; transform: translateY(-4px); transition: opacity 140ms ease, transform 140ms ease; }
.Fadeable.IsShown { opacity: 1; }

/* Apparition en fondu d'un élément qui vient d'arriver (ligne de liste, vue, message) */
/* backwards et pas both : une fois finie, l'animation ne fige plus l'opacité, et un fondu de
   sortie posé ensuite (.IsRemoving, .Sink) joue bien au lieu de couper net */
@keyframes FadeIn { from { opacity: 0; } }
.FadeIn { animation: FadeIn 220ms ease backwards; }
/* Texte remplacé (valeur d'un combo) : le nouveau monte en fondu */
@keyframes TextSwap { from { opacity: 0; transform: translateY(4px); } }
.TextSwap { animation: TextSwap 260ms var(--Ease) backwards; }
/* Disparition avant retrait (demande validée, etc.) */
/* Valeur en direct qui change : fondu + teinte brève (vert si hausse, rouge si baisse) */
@keyframes ValueUp { 0%, 35% { color: var(--Good); } }
@keyframes ValueDown { 0%, 35% { color: var(--Accent); } }
.ValueChanged.IsUp { animation: ValueUp 1400ms ease; }
.ValueChanged.IsDown { animation: ValueDown 1400ms ease; }

/* Chiffres qui roulent (Dom.Roll) : l'ancien descend et s'efface, le nouveau descend d'en haut */
.RollChar { display: inline-block; position: relative; overflow: hidden; vertical-align: bottom; white-space: pre; }
.RollIn { display: inline-block; animation: RollIn 460ms cubic-bezier(.2, .8, .2, 1) both; }
.RollOut { position: absolute; left: 0; top: 0; animation: RollOut 460ms cubic-bezier(.2, .8, .2, 1) both; }
@keyframes RollIn { from { transform: translateY(-75%); opacity: 0; } }
@keyframes RollOut { to { transform: translateY(75%); opacity: 0; } }
.IsRemoving { opacity: 0 !important; transition: opacity var(--Fade); pointer-events: none; }

/* Changement de thème : fondu enchaîné de toute la page (capture avant / après du navigateur) */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 320ms; animation-timing-function: ease; }

/* Onglets et sélecteurs : l'indicateur de l'onglet actif glisse d'un bouton à l'autre */
[data-slide] { position: relative; isolation: isolate; }
.SlideIndicator {
  position: absolute; left: 0; top: 0; z-index: -1; pointer-events: none;
  border-radius: var(--RadiusInner); background: var(--Chip);
  transition: transform 240ms cubic-bezier(.2, .8, .2, 1), width 240ms cubic-bezier(.2, .8, .2, 1), opacity var(--Fade), background-color var(--Fade);
  transform: translateX(var(--X, 0px)) scale(var(--Press, 1));
}
.SlideIndicator.NoSlide { transition: none; }


/* ---------- Connexion ---------- */
.Login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.LoginBox {
  width: 100%; max-width: 320px;
  display: grid; gap: 14px; padding: 28px;
  background: var(--PanelSolid); border-radius: var(--Radius);
}
.LoginBox h1 { margin: 0 0 4px; font-size: 28px; }
.LoginLogo { display: flex; justify-content: center; }
.LoginLogo img { height: 36px; width: auto; }

.LoginBox .BtnPrimary { justify-content: center; height: 36px; margin-top: 4px; }
.LoginBox .BtnPrimary:active { transform: scale(.99); }   /* bouton large : appui plus discret */

/* ---------- Toasts du haut (TopToasts.js) : pile façon iPhone, voir .StackItem ---------- */
.TopToasts { position: fixed; top: 16px; left: 50%; z-index: 70; width: 0; height: 0; }
.TopToast {
  top: 0; left: 0; --Tx: -50%; transform-origin: top center;
  display: flex; align-items: center; gap: 10px;
  width: min(360px, calc(100vw - 32px));
  padding: 10px 16px 10px 12px; font-weight: 500; cursor: pointer;
  background: var(--PanelSolid); border-radius: var(--Radius); box-shadow: var(--Float);
}
.TopToast .ToneIcon { margin-top: 0; }
.TopToastText { min-width: 0; }


/* ---------- Barre du haut ---------- */
.Topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 16px;
  background: var(--Bg);
}
/* La page défile sous la barre : elle s'y efface en fondu au lieu d'être coupée net
   (visible seulement une fois la page défilée, classe posée par Topbar.js) */
.Topbar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 24px;
  background: linear-gradient(var(--Bg), transparent); pointer-events: none;
  opacity: 0; transition: opacity var(--Fade);
}
.Topbar.IsScrolled::after { opacity: 1; }

.TopMark { display: flex; align-items: center; flex: none; }
.TopMark img { width: 28px; height: 28px; }

.ProfileButton {
  display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 200px;
  height: 36px; padding: 0 12px 0 4px;
  border-radius: 999px; text-decoration: none;
}
.ProfileButton:hover, .ProfileButton.IsOn { background: var(--Chip); }
.ProfileName { font-weight: 500; }

/* Onglets du haut : même contrôle segmenté que « Graphique / Tableau » —
   une bande grise, l'onglet actif en bloc clair qui glisse à l'intérieur */
.Nav { display: flex; align-items: center; gap: 2px; min-width: 0; padding: 2px; border-radius: var(--RadiusControl); background: var(--Chip); }
.Nav > .SlideIndicator { background: var(--Raised); }
.Nav a {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px; border-radius: var(--RadiusInner);
  color: var(--Muted); font-weight: 500; text-decoration: none; white-space: nowrap;
}
.Nav a:not(.IsOn):hover { color: var(--Ink); }
.Nav a.IsOn { color: var(--Ink); }
.Nav .Badge { margin-left: 2px; }

.TopActions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.BellWrap { position: relative; }
#BtnBell { position: relative; }
#BtnBell.IsOn { color: var(--Ink); }


/* ---------- Page (fondu entre deux pages) ---------- */
.Page { max-width: 1280px; margin: 0 auto; padding: 24px 16px 56px; transition: opacity var(--Fade); }
.Page.IsLeaving { opacity: 0; }
.PageHead { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 16px; }
.PageHead h1 { margin: 0; font-size: 26px; }

/* Deux colonnes empilées : chaque carte suit la précédente, pas de trou entre les lignes */
.Columns { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; margin-top: 16px; align-items: start; }
.Column { display: grid; gap: 16px; align-content: start; min-width: 0; }


/* ---------- Petits écrans ---------- */
@media (max-width: 1000px) {
  .Columns { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .Topbar { gap: 4px; padding: 0 8px; }
  .NavLabel, .ProfileName { display: none; }
  .ProfileButton { padding: 0 4px; }
  .Nav a { padding: 0 10px; }
  .Page { padding: 16px 8px 40px; }
  .PageHead h1 { font-size: 22px; }
  .Columns, .Column { gap: 8px; }
  .Columns { margin-top: 8px; }
}
.LoginStep:not([hidden]) { display: contents; }
