/* Mise en page de chaque écran. */

/* ---------- Accueil (bento de widgets) ---------- */
.welcome { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.welcome h1 { margin: 0; font-size: var(--t-hero); font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; }
.welcome p { margin: 4px 0 0; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.pick {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); font-size: var(--t-sm); font-weight: 600;
  box-shadow: var(--highlight); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); transition: background var(--dur-fast);
}
.pick:hover { background: var(--card-hover); }
.pick svg { width: 15px; height: 15px; color: var(--muted); }
.pick span { white-space: nowrap; }
.select--pill { height: 38px; box-shadow: var(--highlight); }

/* Widget générique */
.widget { padding: var(--sp-5); }
.widget__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.widget__title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--t-base); font-weight: 650; }
.widget__title svg { width: 16px; height: 16px; color: var(--accent); }
.widget__sub { margin: 3px 0 0; color: var(--muted); font-size: var(--t-sm); }
.widget__value { display: flex; align-items: center; gap: 10px; font-size: var(--t-lg); font-weight: 650; white-space: nowrap; }

/* 4 widgets-chiffres façon iPhone (cliquables → pilotent le graphe) */
.kpi-widgets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-4); }
.kw {
  display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: var(--sp-5); border-radius: var(--r-lg); text-align: left; container-type: inline-size;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--highlight), var(--shadow-card);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  transition: transform var(--dur) var(--ease), border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.kw:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.kw.is-on { border-color: color-mix(in srgb, var(--t) 50%, transparent); box-shadow: var(--highlight), 0 0 0 1px color-mix(in srgb, var(--t) 45%, transparent), var(--shadow-card); }
.kw__head { display: flex; align-items: center; gap: 9px; }
.kw__ic { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 9px; color: var(--t); background: color-mix(in srgb, var(--t) 14%, transparent); }
.kw__ic svg { width: 16px; height: 16px; }
.kw__label { color: var(--ink-2); font-size: var(--t-sm); font-weight: 600; }
.kw__value { font-size: min(var(--t-kpi), 16cqi); font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.kw__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kw__foot .spark { height: 24px; flex: 1; min-width: 40px; max-width: 96px; }

/* Bento : grand graphe + live, puis ventes + répartition */
.bento { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-4); align-items: start; }
.bento--low { margin-top: var(--sp-4); }
.widget--chart .legend-inline { margin-top: var(--sp-4); }

.live-card__num { display: flex; align-items: baseline; gap: 6px; }
.live-card__num strong { font-size: var(--t-lg); font-weight: 700; }
.live-card__num span { color: var(--muted); font-size: var(--t-xs); }
.live-card .globe-wrap { margin: 0 auto var(--sp-2); }
.feed { margin: var(--sp-2) 0 0; padding: 0; list-style: none; }
.feed li { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.feed__main, .feed__side { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.feed__main strong { overflow: hidden; font-size: var(--t-sm); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.feed__main span, .feed__side span { overflow: hidden; color: var(--muted); font-size: var(--t-xs); text-overflow: ellipsis; white-space: nowrap; }
.feed__side { align-items: flex-end; }
.feed__side strong { font-size: var(--t-sm); font-weight: 600; }
/* Le tableau et la répartition occupent toute la largeur du widget. */
.widget .table-wrap { margin: 0 calc(-1 * var(--sp-5)) calc(-1 * var(--sp-5)); }
.widget .table th:first-child, .widget .table td:first-child { padding-left: var(--sp-5); }
.widget .table th:last-child, .widget .table td:last-child { padding-right: var(--sp-5); }

@media (max-width: 1439px) { .bento { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (min-width: 861px) and (max-width: 1279px) { .kpi-widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1100px) {
  .kpi-widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bento, .bento--low { grid-template-columns: minmax(0, 1fr); }
}
/* Une seule colonne : le globe et le fil des ventes côte à côte plutôt qu'un globe perdu au milieu. */
@media (min-width: 561px) and (max-width: 1100px) {
  .live-card { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); column-gap: var(--sp-6); align-items: center; }
  .live-card .widget__head { grid-column: 1 / -1; }
  .live-card .globe-wrap, .live-card .feed { margin: 0; }
}
@media (max-width: 760px) {
  .widget__head { flex-wrap: wrap; }
  .widget--chart .widget__value { order: 3; }
  .pick, .select--pill { height: 40px; }
  .select--pill { font-size: 16px; }
}
@media (max-width: 860px) { .widget__head .link { height: 40px; } }
@media (max-width: 520px) {
  .kpi-widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .kw { padding: var(--sp-4); }
  .kw__value { font-size: min(1.5rem, 16cqi); }
  .kw__foot .spark { display: none; }
  .toolbar { width: 100%; }
  .toolbar .pick, .toolbar .select { flex: 1 0 auto; }
  .toolbar .pick span { flex: 1; text-align: left; }
}
@media (max-width: 359px) { .kpi-widgets { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Ventes ---------- */
.tools { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); }
.tools__count { margin-left: auto; color: var(--muted); font-size: var(--t-sm); }
.more { display: flex; justify-content: center; padding: var(--sp-4); border-top: 1px solid var(--line); }
@media (max-width: 860px) {
  .tools .seg button, .tools .select, .more .btn { height: 40px; }
}
@media (max-width: 760px) {
  .tools .seg { width: 100%; overflow-x: auto; }
  .tools .seg button { flex: 1 0 auto; padding: 0 8px; }
  .tools .select { flex: 1; font-size: 16px; }
  .tools__count { display: none; }
}
/* Sous 375 px, les 4 filtres ne tiennent pas sur une ligne : 2×2 plutôt qu'un libellé coupé. */
@media (max-width: 374px) {
  .tools .seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-radius: var(--r-md); }
}

/* Bandeau de 3 chiffres (pages Ventes et Shops). */
.strip { display: inline-flex; border-radius: var(--r-md); background: var(--card); border: 1px solid var(--line); box-shadow: var(--highlight), var(--shadow-card); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.strip > div { display: flex; flex-direction: column; justify-content: center; padding: 8px 18px; line-height: 1.3; }
.strip > div + div { border-left: 1px solid var(--line); }
.strip span { color: var(--muted); font-size: var(--t-2xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.strip strong { font-size: var(--t-lg); font-weight: 650; }
@media (max-width: 760px) {
  .strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .strip > div { padding: 8px 12px; }
}
@media (max-width: 400px) {
  .strip { grid-template-columns: repeat(3, auto); }
  .strip > div { padding: 8px 10px; }
}

/* ---------- Shops ---------- */
.shops { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: var(--sp-4); }
.shop { padding: var(--sp-5); transition: border-color var(--dur-fast), background var(--dur-fast); }
.shop:hover { border-color: var(--line-strong); background: var(--card-hover); }
.shop__top { display: flex; align-items: center; gap: var(--sp-3); }
.shop__top .mark { width: 40px; height: 40px; border-radius: 10px; font-size: var(--t-sm); }
.shop__name { margin: 0; font-size: var(--t-lg); font-weight: 600; }
.shop__state { margin-top: 3px; }
.shop__figure { margin: var(--sp-5) 0 var(--sp-3); }
.shop__figure span { display: block; color: var(--muted); font-size: var(--t-2xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.shop__figure strong { display: block; margin-top: 4px; font-size: var(--t-kpi); font-weight: 650; line-height: 1.1; }
.shop__facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); margin: var(--sp-4) 0 0; }
.shop__facts div { padding: 10px 12px; border-radius: var(--r-md); background: var(--well); border: 1px solid var(--line); }
.shop__facts dt { color: var(--muted); font-size: var(--t-xs); }
.shop__facts dd { margin: 2px 0 0; font-size: var(--t-base); font-weight: 600; }

/* ---------- Connexion ---------- */
.login-wrap { display: grid; place-items: center; min-height: 100dvh; padding: var(--sp-5); }
.login {
  width: min(100%, 400px); padding: var(--sp-7); border-radius: 18px; background: var(--card); border: 1px solid var(--line-strong);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--highlight), var(--shadow-pop);
}
.login__brand { display: flex; align-items: center; }
.login h1 { margin: var(--sp-6) 0 4px; font-size: var(--t-xl); font-weight: 650; letter-spacing: -0.02em; }
.login p { margin: 0 0 var(--sp-6); color: var(--muted); font-size: var(--t-base); }
.login form { display: grid; gap: var(--sp-4); }
.login .btn { height: 42px; margin-top: var(--sp-1); }
.login__error { margin: 0; color: var(--bad); font-size: var(--t-sm); font-weight: 500; }
.login__error:empty { display: none; }
.login__foot { margin-top: var(--sp-5); color: var(--faint); font-size: var(--t-xs); text-align: center; }
.login .login__foot { margin: var(--sp-5) 0 0; }
.login .login__error { margin: 0; }
