/* =====================================================================
   Manager Radio — Composants & layout
   ===================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: var(--fw-semibold); }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Scrollbars discrètes */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }

/* ------------------------------------------------------------ Utilitaires */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
.spacer { flex: 1 1 auto; }
.text-right { text-align: right; }

/* =============================================================== SHELL */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Voile de navigation : masqué (hors grille) sur desktop, affiché en mobile. */
.nav-backdrop { display: none; }

/* ---- Sidebar ---- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-4);
}
.brand__logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(140deg, var(--accent), var(--accent-700));
  color: #fff;
  box-shadow: var(--shadow-accent);
  flex-shrink: 0;
}
.brand__logo svg { width: 22px; height: 22px; }
.brand__name { font-weight: var(--fw-bold); font-size: var(--fs-md); letter-spacing: -0.01em; }
.brand__sub { font-size: var(--fs-xs); color: var(--text-faint); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__label {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); font-weight: var(--fw-semibold);
  padding: var(--space-3) var(--space-2) var(--space-1);
}
.nav__item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  border: none; background: none; width: 100%; text-align: left;
  font-size: var(--fs-base);
}
.nav__item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav__item.is-active { background: var(--accent-soft); color: var(--accent-600); font-weight: var(--fw-semibold); }
.nav__item svg { width: 19px; height: 19px; flex-shrink: 0; }

.sidebar__foot { margin-top: auto; padding-top: var(--space-3); border-top: 1px solid var(--border); }

/* ---- Topbar ---- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-5);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.topbar__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); letter-spacing: -0.01em; }
.topbar .hamburger { display: none; }

.content {
  padding: var(--space-6) var(--space-5);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* ---- Radio selector (topbar) ---- */
.radio-select {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}
.radio-select select {
  border: none; background: none; color: var(--text);
  font-weight: var(--fw-semibold); font-size: var(--fs-base);
  padding: var(--space-1) var(--space-5) var(--space-1) 0;
  cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236a6a78' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 4px center;
}
.radio-select select:focus { outline: none; }

/* =============================================================== BOUTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: var(--fs-base); font-weight: var(--fw-semibold);
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-accent); }
.btn--primary:hover { background: var(--accent-600); text-decoration: none; }
.btn--ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn--subtle { background: var(--surface-2); color: var(--text); }
.btn--subtle:hover { background: var(--surface-3); text-decoration: none; }
.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; text-decoration: none; }
.btn--sm { padding: var(--space-1) var(--space-3); font-size: var(--fs-sm); border-radius: 7px; }
.btn--icon { padding: var(--space-2); width: 36px; height: 36px; }
.btn--icon.btn--sm { width: 30px; height: 30px; padding: 0; }
.btn--block { width: 100%; }

/* Ajustements thème sombre — contraste WCAG AA */
:root[data-theme="dark"] .btn--primary { background: #5b4be8; }
:root[data-theme="dark"] .btn--primary:hover { background: #6355e6; }
:root[data-theme="dark"] .input,
:root[data-theme="dark"] .select,
:root[data-theme="dark"] .textarea { background: var(--surface-2); }

/* =============================================================== CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.card__body { padding: var(--space-5); }

.grid { display: grid; gap: var(--space-4); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* Page header */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap;
}
.page-head h1 { font-size: var(--fs-2xl); letter-spacing: -0.02em; }
.page-head p { color: var(--text-muted); margin-top: var(--space-1); }

/* =============================================================== BADGES */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 3px var(--space-2); border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  background: var(--surface-2); color: var(--text-muted);
}
.badge--accent { background: var(--accent-soft); color: var(--accent-600); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.live {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 4px var(--space-3); border-radius: var(--radius-full);
  background: var(--danger-soft); color: var(--on-air);
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.live__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--on-air); animation: pulse 1.8s var(--ease) infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.7); } }

/* =============================================================== FORMS */
.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.field__label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text); }
.field__hint { font-size: var(--fs-xs); color: var(--text-faint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

.input, .select, .textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-base); font-family: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  min-height: 40px;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236a6a78' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px;
}

.input-group { position: relative; }
.input-group svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-faint); }
.input-group .input { padding-left: 38px; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track {
  width: 40px; height: 23px; border-radius: 999px; background: var(--surface-3);
  position: relative; transition: background var(--dur) var(--ease); flex-shrink: 0;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Meta editor (paires clé/valeur) */
.meta-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: var(--space-2); margin-bottom: var(--space-2); }

/* =============================================================== TABLE */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table th {
  text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint); font-weight: var(--fw-semibold);
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); white-space: nowrap;
}
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover { background: var(--surface-hover); }
.table__actions { display: flex; gap: var(--space-1); justify-content: flex-end; }

.cell-media { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.thumb {
  width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0;
  background: var(--surface-2); display: grid; place-items: center; color: var(--text-faint);
}
.thumb svg { width: 18px; height: 18px; }
.thumb--lg { width: 64px; height: 64px; }

/* =============================================================== MODAL */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 10, 18, 0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--space-6) var(--space-4);
  overflow-y: auto;
  animation: fade var(--dur) var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 560px; margin: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  animation: pop var(--dur-slow) var(--ease);
}
.modal--lg { max-width: 860px; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.modal__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.modal__body { padding: var(--space-5); max-height: 66vh; overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); }

/* =============================================================== TOASTS */
.toasts { position: fixed; bottom: var(--space-5); right: var(--space-5); z-index: 200; display: flex; flex-direction: column; gap: var(--space-2); }
.toast {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 260px; max-width: 380px;
  animation: slidein var(--dur-slow) var(--ease);
}
.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast--success svg { color: var(--success); } .toast--error svg { color: var(--danger); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* =============================================================== EMPTY */
.empty { text-align: center; padding: var(--space-7) var(--space-4); color: var(--text-muted); }
.empty__icon { width: 56px; height: 56px; margin: 0 auto var(--space-4); display: grid; place-items: center; border-radius: var(--radius-lg); background: var(--surface-2); color: var(--text-faint); }
.empty__icon svg { width: 28px; height: 28px; }
.empty h3 { font-size: var(--fs-md); margin-bottom: var(--space-1); color: var(--text); }

/* =============================================================== SKELETON */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* =============================================================== LOGIN */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: var(--space-4); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: var(--space-6); }
.login-card .brand { justify-content: center; padding-top: 0; }
.login-card h1 { text-align: center; font-size: var(--fs-xl); margin-bottom: var(--space-1); }
.login-card p { text-align: center; color: var(--text-muted); margin-bottom: var(--space-5); }

/* =============================================================== NOW PLAYING */
.onair-card {
  position: relative; overflow: hidden;
  border-radius: var(--radius-xl); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow);
  padding: var(--space-6);
  display: grid; grid-template-columns: 200px 1fr; gap: var(--space-6); align-items: center;
}
.onair-card__bg { position: absolute; inset: 0; z-index: 0; opacity: .16; filter: blur(40px) saturate(160%); transform: scale(1.2); background-size: cover; background-position: center; }
.onair-card > * { position: relative; z-index: 1; }
.onair-art {
  width: 200px; height: 200px; border-radius: var(--radius-lg); object-fit: cover;
  box-shadow: var(--shadow-lg); background: var(--surface-2);
  display: grid; place-items: center; color: var(--text-faint);
}
.onair-art svg { width: 56px; height: 56px; }
.onair-meta { min-width: 0; }
.onair-title { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; margin: var(--space-2) 0 var(--space-1); }
.onair-artist { font-size: var(--fs-lg); color: var(--text-muted); }
.onair-sub { margin-top: var(--space-3); display: flex; gap: var(--space-2); flex-wrap: wrap; }

.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: var(--space-4); }
.progress__bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-600)); border-radius: 999px; transition: width 1s linear; }
.progress-time { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-faint); margin-top: var(--space-2); font-variant-numeric: tabular-nums; }

/* Track list (history / queue) */
.tracklist { display: flex; flex-direction: column; }
.tracklist__item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.tracklist__item:last-child { border-bottom: none; }
.tracklist__idx { width: 22px; text-align: center; color: var(--text-faint); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.tracklist__info { min-width: 0; flex: 1; }
.tracklist__title { font-weight: var(--fw-medium); }
.tracklist__time { color: var(--text-faint); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }

/* =============================================================== SCHEDULE GRID */
.schedule { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.schedule__grid { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); min-width: 900px; }
.schedule__day { border-right: 1px solid var(--border); min-height: 200px; }
.schedule__day:last-child { border-right: none; }
.schedule__dayhead { padding: var(--space-3); font-weight: var(--fw-semibold); font-size: var(--fs-sm); text-align: center; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-2); }
.schedule__slot {
  margin: var(--space-2); padding: var(--space-3);
  border-radius: var(--radius-sm); background: var(--accent-soft);
  border-left: 3px solid var(--accent); cursor: pointer;
  transition: transform var(--dur) var(--ease);
}
.schedule__slot:hover { transform: translateY(-1px); }
.schedule__slot-time { font-size: var(--fs-xs); color: var(--accent-600); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.schedule__slot-title { font-weight: var(--fw-semibold); font-size: var(--fs-sm); margin-top: 2px; }
.schedule__slot-host { font-size: var(--fs-xs); color: var(--text-muted); }

/* =============================================================== PLAYLIST EDITOR */
.picker { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.picker__col { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; max-height: 460px; }
.picker__head { padding: var(--space-3); border-bottom: 1px solid var(--border); font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.picker__list { overflow-y: auto; flex: 1; }
.picker__item { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
.picker__item:last-child { border-bottom: none; }
.picker__item-info { min-width: 0; flex: 1; }
.picker__item-title { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.picker__item-sub { font-size: var(--fs-xs); color: var(--text-faint); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-4); }
.stat { padding: var(--space-4) var(--space-5); }
.stat__value { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.stat__label { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }

/* Code / snippet */
.snippet { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); font-family: var(--font-mono); font-size: var(--fs-sm); overflow-x: auto; white-space: pre; color: var(--text); }

/* =============================================================== DATAVIZ */
.chart-svg { display: block; width: 100%; overflow: visible; }
.chart-axis { fill: var(--chart-muted); font-size: 11px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart-hlabel { fill: var(--chart-ink); font-size: 13px; font-weight: 600; font-family: var(--font-sans); }
.chart-hsub { fill: var(--chart-muted); font-size: 11px; font-family: var(--font-sans); }
.chart-center-v { fill: var(--chart-ink); font-size: 22px; font-weight: 700; font-family: var(--font-sans); }
.chart-center-l { fill: var(--chart-muted); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; font-family: var(--font-sans); }
.chart-bar { transition: fill-opacity var(--dur) var(--ease); }
.chart-bar:hover { fill-opacity: .82; }
.chart-slice { transition: opacity var(--dur) var(--ease); cursor: default; }
.chart-slice:hover { opacity: .82; }
.chart-spark { display: block; }
.chart-empty { display: grid; place-items: center; color: var(--text-faint); font-size: var(--fs-sm); border: 1px dashed var(--border); border-radius: var(--radius); }

.chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: var(--space-3); }
.chart-legend__item { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); color: var(--text-muted); }
.chart-legend__dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.chart-legend__v { color: var(--text); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.chart-donut { display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; }
.chart-donut > .chart-legend { flex-direction: column; gap: var(--space-2); margin-top: 0; }

.chart-tip {
  position: fixed; z-index: 300; pointer-events: none; display: none;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: var(--space-2) var(--space-3); font-size: var(--fs-sm); min-width: 130px;
}
.chart-tip__t { font-weight: var(--fw-semibold); color: var(--text); margin-bottom: var(--space-1); }
.chart-tip__row { display: flex; align-items: center; gap: var(--space-2); line-height: 1.6; }
.chart-tip__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.chart-tip__k { color: var(--text-muted); }
.chart-tip__v { margin-left: auto; font-weight: var(--fw-semibold); color: var(--text); font-variant-numeric: tabular-nums; }

/* --- Tuiles KPI --- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-4); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--space-2); position: relative; overflow: hidden;
}
.kpi__label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-medium); }
.kpi__value { font-size: var(--fs-3xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; line-height: 1; }
.kpi__row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-2); }
.kpi__delta { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: var(--fw-semibold); padding: 2px 7px; border-radius: var(--radius-full); }
.kpi__delta svg { width: 13px; height: 13px; }
.kpi__delta--up { background: var(--success-soft); color: var(--success); }
.kpi__delta--down { background: var(--danger-soft); color: var(--danger); }
.kpi__delta--flat { background: var(--surface-2); color: var(--text-faint); }
.kpi__spark { position: absolute; right: 0; bottom: 0; width: 120px; height: 34px; opacity: .9; }
.kpi--hero { grid-column: span 2; background: linear-gradient(135deg, var(--accent), var(--accent-700)); border: none; color: #fff; box-shadow: var(--shadow-accent); }
.kpi--hero .kpi__label { color: rgba(255,255,255,.85); }
.kpi--hero .kpi__value { font-size: 3rem; }
.kpi--hero .kpi__delta { background: rgba(255,255,255,.2); color: #fff; }

/* --- Panneau de chart --- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5) var(--space-2); }
.panel__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.panel__sub { font-size: var(--fs-xs); color: var(--text-faint); }
.panel__body { padding: var(--space-3) var(--space-5) var(--space-5); }
.analytics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-5); }
.analytics-grid .span-2 { grid-column: span 2; }

/* --- Segmented control (plages de dates) --- */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented button { border: none; background: none; color: var(--text-muted); font-weight: var(--fw-semibold); font-size: var(--fs-sm); padding: var(--space-1) var(--space-3); border-radius: 6px; cursor: pointer; transition: all var(--dur) var(--ease); }
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--surface); color: var(--accent-600); box-shadow: var(--shadow-sm); }

/* --- Live pill --- */
.live-pill { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); background: var(--success-soft); color: var(--success); font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.live-pill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 1.8s var(--ease) infinite; }

/* --- Now-playing compact (dashboard) --- */
.np { display: flex; gap: var(--space-4); align-items: center; }
.np-art { width: 96px; height: 96px; border-radius: var(--radius); object-fit: cover; display: grid; place-items: center; background: var(--surface-2); color: var(--text-faint); flex-shrink: 0; box-shadow: var(--shadow); }
.np-art svg { width: 32px; height: 32px; }
.np__meta { min-width: 0; flex: 1; }
.np__title { font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: -0.01em; }
.np__artist { color: var(--text-muted); }
.np-next-wrap { margin-top: var(--space-4); border-top: 1px solid var(--border); padding-top: var(--space-3); }
.np-next { display: flex; flex-direction: column; gap: var(--space-2); }
.np-next__item { display: flex; align-items: center; gap: var(--space-3); font-size: var(--fs-sm); color: var(--text-muted); }
.np-next__time { color: var(--text-faint); flex-shrink: 0; font-variant-numeric: tabular-nums; }

@media (max-width: 780px) {
  .analytics-grid { grid-template-columns: 1fr; }
  .analytics-grid .span-2 { grid-column: span 1; }
  .kpi--hero { grid-column: span 1; }
}

/* =============================================================== RESPONSIVE */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px;
    transform: translateX(-100%);
    visibility: hidden; /* hors-écran : non focalisable au clavier */
    transition: transform var(--dur-slow) var(--ease), visibility var(--dur-slow) var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar { transform: none; visibility: visible; }
  .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease); }
  .app.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .topbar .hamburger { display: inline-flex; }
  .onair-card { grid-template-columns: 1fr; text-align: center; }
  .onair-art { width: 160px; height: 160px; margin: 0 auto; }
  .onair-sub { justify-content: center; }
}
@media (max-width: 640px) {
  .content { padding: var(--space-4) var(--space-4); }
  .topbar { padding: 0 var(--space-4); gap: var(--space-2); }
  .topbar__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .field-row { grid-template-columns: 1fr; }
  .picker { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head h1 { font-size: var(--fs-xl); }
  .radio-select { flex-shrink: 0; }
  .radio-select select { max-width: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
