/* ───────────────────────── Panel ───────────────────────── */
body { background: var(--bg-soft); }
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 22px; animation: fade .4s; }
.boot img { animation: float 2.4s ease-in-out infinite; }
.boot-bar { width: 140px; height: 4px; border-radius: 9px; background: var(--bg-sunken); overflow: hidden; }
.boot-bar span { display: block; width: 40%; height: 100%; background: var(--brand-grad); border-radius: 9px; animation: bootbar 1.1s ease-in-out infinite; }
@keyframes bootbar { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

.layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: 100vh; }

/* Barre latérale */
.side { position: sticky; top: 0; height: 100vh; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 50; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px 14px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; color: var(--text); text-decoration: none !important; }
.brand img { width: 30px; height: 30px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; scrollbar-width: thin; }
.nav-group { margin-top: 14px; }
.nav-label { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; padding: 0 10px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--muted); font-weight: 500; font-size: 14px;
  text-decoration: none !important; position: relative; transition: background .15s, color .15s; border: 0; background: none; width: 100%;
}
.nav-link:hover { background: var(--bg-soft); color: var(--text); }
.nav-link.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.nav-link.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); animation: grow .3s var(--ease); }
.nav-new { margin-left: auto; font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: var(--brand-grad); color: #fff; letter-spacing: .03em; }
.side-foot { border-top: 1px solid var(--border); padding: 10px 12px; }

/* Sélecteur de bot */
.switcher { position: relative; padding: 0 12px; }
.switch-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 12px; background: #fff; text-align: left; transition: border-color .2s, box-shadow .2s; }
.switch-btn:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.switch-btn b { font-size: 14px; display: block; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.switch-pop { display: none; position: absolute; left: 12px; right: 12px; top: calc(100% + 6px); background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 70; animation: popIn .18s var(--ease); }
.switcher.open .switch-pop { display: block; }
.switch-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 9px; color: var(--text); text-decoration: none !important; }
.switch-item:hover, .switch-item.active { background: var(--bg-soft); }
.switch-item.add { color: var(--brand-ink); }
.avatar.plus { display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }

/* Zone principale */
.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: 62px; display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: rgba(247, 248, 251, .82); backdrop-filter: saturate(1.6) blur(12px); border-bottom: 1px solid var(--border);
}
.crumb { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; }
.menu-toggle { display: none; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 99px; border: 1px solid var(--border); background: #fff; font-weight: 600; font-size: 13.5px; }
.user-btn .avatar { width: 28px; height: 28px; }
.user-menu .menu { display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; animation: popIn .18s var(--ease); }
.user-menu.open .menu { display: block; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: none; color: var(--text); font-size: 13.5px; text-decoration: none !important; }
.menu-item:hover { background: var(--bg-soft); }
.menu-item.danger { color: var(--danger); }

.page { max-width: 1120px; margin: 0 auto; padding: 28px 28px 120px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -.03em; }
.page-head p { max-width: 720px; margin-top: 6px; font-size: 14px; }
.mb16 { margin-bottom: 16px; } .mb8 { margin-bottom: 8px; }
.grow { flex: 1; min-width: 0; }
.sticky { position: sticky; top: 80px; }
.page .card + .card, .page .card + .grid, .page .grid + .card, .page .alert + .grid, .page .grid + .alert { margin-top: 16px; }

/* Incidents */
.incidents { display: flex; flex-direction: column; }
.incident { display: flex; align-items: flex-start; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); transition: background .15s; }
.incident:first-child { border-top: 0; }
.incident:hover { background: #fcfcfe; }
.incident .dot { margin-top: 7px; }
.checklist { display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 500; }

/* Installation */
.step { display: flex; gap: 16px; padding: 20px; }
.step h3 { font-size: 16px; margin-bottom: 4px; }
.step-side { padding-top: 2px; }
.step-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); color: var(--muted); font-weight: 700; font-size: 13px; }
.step-num.ok { background: var(--success); border-color: var(--success); color: #fff; animation: pop .4s var(--ease); }
.botcard { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft); flex-wrap: wrap; }
.guilds { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.guild { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; transition: all .2s var(--ease); background: #fff; }
.guild:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.guild.selected { border-color: var(--brand); box-shadow: var(--ring); }
.guild.missing { opacity: .75; }
.ginit { display: grid; place-items: center; font-weight: 700; color: var(--brand-ink); background: var(--brand-soft); }
.tuto { border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft); }
.tuto summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; list-style: none; }
.tuto summary::-webkit-details-marker { display: none; }
.tuto ol { margin: 0; padding: 0 18px 14px 36px; font-size: 13.5px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.todo { margin: 10px 0 0; padding-left: 18px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }

/* Niveaux d'accès */
.level-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: #fff; }
.level-card h4 { font-size: 14.5px; margin-bottom: 4px; }

/* Listes éditables */
.subcard { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--bg-soft); }
.list-row { display: flex; gap: 8px; align-items: center; }
.list-row > * { min-width: 0; }
.list-row .select { width: 150px; flex: none; }

/* Giveaways */
.gw-row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--border); }
.gw-row:first-child { border-top: 0; }
.gw-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--warning-soft); font-size: 18px; }

/* Chat de test IA */
.chat { height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; scroll-behavior: smooth; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.5; animation: fadeUp .3s var(--ease); word-wrap: break-word; }
.bubble.bot { background: var(--bg-sunken); border-bottom-left-radius: 6px; align-self: flex-start; }
.bubble.me { background: var(--brand-grad); color: #fff; border-bottom-right-radius: 6px; align-self: flex-end; }
.bubble.err { background: var(--danger-soft); color: var(--danger); }
.bubble.typing { display: flex; gap: 4px; padding: 14px; }
.bubble.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: pulse 1s infinite; }
.bubble.typing span:nth-child(2) { animation-delay: .15s; } .bubble.typing span:nth-child(3) { animation-delay: .3s; }

/* Constructeur IA */
.builder-hero { position: relative; overflow: hidden; border: 1px solid #dcdfff; }
.builder-hero::before { content: ''; position: absolute; inset: -40% -10% auto auto; width: 420px; height: 420px; background: radial-gradient(circle, rgba(124, 58, 237, .12), transparent 60%); pointer-events: none; animation: blob 14s ease-in-out infinite; }
.builder-prompt { font-size: 16px; min-height: 110px; border-radius: 14px; padding: 14px 16px; position: relative; }
.builder-loading { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px; }
.orb { width: 64px; height: 64px; border-radius: 50%; background: var(--brand-grad); animation: orb 1.6s ease-in-out infinite; box-shadow: 0 0 0 0 rgba(99, 102, 241, .5); margin-bottom: 8px; }
@keyframes orb { 0% { transform: scale(.9); box-shadow: 0 0 0 0 rgba(99, 102, 241, .45); } 70% { transform: scale(1); box-shadow: 0 0 0 26px rgba(99, 102, 241, 0); } 100% { transform: scale(.9); } }
.plan-role { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 13.5px; }
.plan-tree { display: flex; flex-direction: column; gap: 14px; }
.plan-cat-name { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.plan-ch { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 8px; font-size: 14px; color: var(--muted); }
.plan-ch:hover { background: var(--bg-soft); color: var(--text); }
.x-btn { margin-left: auto; width: 22px; height: 22px; border-radius: 6px; border: 0; background: transparent; color: var(--faint); opacity: 0; transition: opacity .15s; }
.plan-ch:hover .x-btn, .plan-role:hover .x-btn, .plan-cat-name:hover .x-btn { opacity: 1; }
.x-btn:hover { background: var(--danger-soft); color: var(--danger); }

/* Profil */
.profile-card { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.profile-banner { height: 110px; background: var(--brand-grad); background-size: cover; background-position: center; }
.profile-row { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 14px 14px; margin-top: -36px; }
.profile-avatar { width: 80px; height: 80px; border-radius: 50%; border: 5px solid #fff; background: #fff; object-fit: cover; }
.color-input { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px; padding: 3px; background: #fff; cursor: pointer; }

.danger-zone { border-color: #fecdd6; }
.dc-mention { background: rgba(88, 101, 242, .15); color: #4752c4; border-radius: 4px; padding: 0 2px; font-weight: 500; }
.chart-wrap svg { display: block; overflow: visible; }

.scrim { display: none; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); transition: transform .35s var(--ease); box-shadow: var(--shadow-lg); }
  .nav-open .side { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 18, 34, .3); z-index: 45; animation: fade .2s; }
  .menu-toggle { display: inline-flex; }
  .page .grid[style] { grid-template-columns: 1fr !important; }
  .sticky { position: static; }
  .topbar { padding: 0 14px; }
  .page { padding: 20px 14px 120px; }
  .hide-sm { display: none; }
  .row-setting { flex-wrap: wrap; }
  .row-setting > div:last-child:not(.grow) { width: 100% !important; }
}

/* Les grilles et piles gèrent leur propre espacement */
.grid > .card, .stack > .card, .grid > .sticky, .stack > .alert { margin-top: 0 !important; }

/* Panel admin */
.kpi { position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, rgba(99, 102, 241, .08), transparent 70%); }
.hbars { display: flex; flex-direction: column; gap: 14px; }
.hbar-track { height: 8px; border-radius: 9px; background: var(--bg-sunken); margin-top: 6px; overflow: hidden; }
.hbar-track span { display: block; height: 100%; border-radius: 9px; background: var(--brand-grad); transform-origin: left; animation: hgrow .9s var(--ease) both; }
@keyframes hgrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (max-width: 640px) {
  .crumb .faint, .crumb .i:first-of-type { display: none; }
  .topbar .badge { display: none; }
  .page-head h1 { font-size: 21px; }
}
