/* ═══════════════════════════════════════════════════════════
   XYZ Panel — design system (style NYRA Management)
   bg #0E0E10 · panel #151517 · border #232327 · accent #D2FD3C
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #0E0E10;
  --panel: #151517;
  --panel-2: #1B1B1E;
  --panel-3: #121214;
  --border: #232327;
  --border-soft: rgba(35, 35, 39, 0.6);
  --accent: #D2FD3C;
  --accent-ink: #0E0E10;
  --accent-dim: rgba(210, 253, 60, 0.15);
  --accent-glow: 0 0 24px -8px rgba(210, 253, 60, 0.55);
  --muted: #8A8A90;
  --text: #ffffff;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fcd34d;
  --warn: #f59e0b;
  --warn-dim: rgba(245, 158, 11, 0.13);
  --sky: #7dd3fc;
  --violet: #c4b5fd;
  --radius: 14px;
  --radius-lg: 18px;
  --font: "DM Sans", Inter, system-ui, -apple-system, sans-serif;
  --mono: "DM Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #2d2d31; }
::-webkit-scrollbar-track { background: transparent; }

::selection { background: var(--accent-dim); color: var(--text); }

/* ── Layout ─────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  padding: 28px 32px 48px;
  max-width: 1440px;
  width: 100%;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  box-shadow: var(--accent-glow);
  flex-shrink: 0;
}

.brand-name { font-size: 14px; font-weight: 600; line-height: 1.25; }
.brand-sub  { font-size: 11px; color: var(--muted); margin-top: 2px; }

.sidebar nav { flex: 1; overflow-y: auto; padding: 8px 0; }

.section-label {
  padding: 16px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: rgba(138, 138, 144, 0.8);
  text-transform: uppercase;
}

.nav-group { padding: 0 8px; display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background-color 0.15s, color 0.15s;
}

.nav-link svg { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }

.nav-link:hover { background: var(--panel-2); color: var(--text); }

.nav-link.active {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--border);
}

.sidebar-foot { border-top: 1px solid var(--border); padding: 12px; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(14, 14, 16, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

/* status pulse */
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
  animation: pulse 2.4s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ── Cards / panels ─────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.card-soft {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* metric cards row */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.2s, transform 0.2s;
}

.stat:hover { border-color: #2d2d31; transform: translateY(-1px); }

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-ic {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-dim);
  border: 1px solid rgba(210, 253, 60, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-ic svg { width: 15px; height: 15px; color: var(--accent); }

.stat-value {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 15px;
  color: var(--muted);
  margin-left: 6px;
  font-weight: 400;
}

.stat-foot { margin-top: 12px; display: flex; align-items: center; gap: 8px; }

/* thin progress bar */
.bar {
  flex: 1;
  height: 4px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(210, 253, 60, 0.4);
  transition: width 0.6s ease;
}

.bar-pct {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

/* panels with header */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel + .panel { margin-top: 16px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-title { font-size: 14px; font-weight: 600; }

.panel-body { padding: 20px; }

.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

/* empty state */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 20px;
  text-align: center;
}

.empty svg { width: 28px; height: 28px; color: var(--muted); opacity: 0.7; }

.empty-title { font-size: 13px; font-weight: 600; color: var(--text); }
.empty-text  { font-size: 12.5px; color: var(--muted); max-width: 320px; }

.spark-placeholder { width: 100%; height: auto; display: block; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-accent { background: var(--accent-dim);            color: var(--accent); border: 1px solid rgba(210, 253, 60, 0.25); }
.badge-green  { background: rgba(16, 185, 129, 0.10);     color: var(--green);  border: 1px solid rgba(16, 185, 129, 0.20); }
.badge-red    { background: rgba(239, 68, 68, 0.10);      color: var(--red);    border: 1px solid rgba(239, 68, 68, 0.20); }
.badge-yellow { background: rgba(245, 158, 11, 0.10);     color: var(--yellow); border: 1px solid rgba(245, 158, 11, 0.20); }
.badge-sky    { background: rgba(14, 165, 233, 0.12);     color: var(--sky);    border: 1px solid rgba(14, 165, 233, 0.25); }
.badge-violet { background: rgba(139, 92, 246, 0.15);     color: var(--violet); border: 1px solid rgba(139, 92, 246, 0.30); }
.badge-gray   { background: var(--panel-2);               color: var(--muted);  border: 1px solid var(--border); }

.badge .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

/* A badge that is also a clickable control (e.g. the scheduler / proxy
   ON·OFF toggles rendered as <button class="badge ...">). */
.badge-toggle { cursor: pointer; border-style: solid; }
.badge-toggle:hover { filter: brightness(1.12); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, filter 0.15s;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--panel-2); }

.btn-danger { background: #ef4444; color: #fff; font-weight: 600; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

/* Violet — reserved for the "resolve challenge" action so it reads as a
   deliberate, distinct recovery step rather than a generic grey button. */
.btn-violet { background: #8b5cf6; color: #fff; font-weight: 600; }
.btn-violet:hover:not(:disabled) { background: #7c3aed; }

/* Warning — amber action (uses the shared --warn token). */
.btn-warn { background: var(--warn); color: var(--accent-ink); font-weight: 600; }
.btn-warn:hover:not(:disabled) { filter: brightness(1.08); }

.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; }

/* ── Forms ──────────────────────────────────────────────── */
.label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input {
  width: 100%;
  background: var(--panel-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font);
}

.input:focus { outline: none; border-color: rgba(210, 253, 60, 0.6); }
.input::placeholder { color: var(--muted); }

/* ── Tables ─────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }

.table th {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-soft);
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color 0.1s; }
.table tbody tr:hover { background: rgba(27, 27, 30, 0.5); }

/* ── Utilities ──────────────────────────────────────────── */
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* Vertical rhythm — one consistent gap (16px) between stacked blocks,
   matching the default `.panel + .panel` spacing. Prefer these over
   ad-hoc inline margins so the whole app breathes the same way. */
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }

/* Page back-link row (used at the top of detail/sub pages) */
.page-back { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.page-back .btn { font-size: 13px; }

/* ── Action toolbar ─────────────────────────────────────────
   A calm row of related actions with subtle separators between
   groups, instead of a wall of identical buttons. */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── Login page ─────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(600px 300px at 50% -5%, rgba(210, 253, 60, 0.07), transparent 70%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px 32px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-brand .brand-logo { width: 44px; height: 44px; border-radius: 13px; font-size: 17px; }

.login-title { font-size: 16px; font-weight: 600; line-height: 1.25; }
.login-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }

.login-card .field { margin-bottom: 16px; }

.login-card .btn-primary { margin-top: 8px; padding: 10px 14px; }

.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 18px;
}

.login-foot {
  margin-top: 24px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Flash banner (one-shot) ────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 20px;
  border: 1px solid;
  animation: flash-in 0.25s ease;
}

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flash-dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; flex-shrink: 0; }

.flash-success { background: rgba(16, 185, 129, 0.08);  border-color: rgba(16, 185, 129, 0.25);  color: var(--green); }
.flash-error   { background: rgba(239, 68, 68, 0.08);   border-color: rgba(239, 68, 68, 0.25);   color: var(--red); }
.flash-warning { background: rgba(245, 158, 11, 0.08);  border-color: rgba(245, 158, 11, 0.25);  color: var(--yellow); }
.flash-info    { background: rgba(14, 165, 233, 0.08);  border-color: rgba(14, 165, 233, 0.25);  color: var(--sky); }

.flash span:last-child { color: var(--text); }

/* ── Page layout helpers / forms ────────────────────────── */
.page-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .form-span { grid-column: 1 / -1; }

.form-foot {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}

.help { font-size: 12px; color: var(--muted); }

textarea.input { resize: vertical; min-height: 90px; line-height: 1.6; }

select.input { cursor: pointer; }
select.input option { background: var(--panel-2); color: var(--text); }

/* ── Table helpers ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }

.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline-block; margin-left: 4px; }

/* ── Collapsible disclosure box ─────────────────────────────
   Shared by "Ajouter des comptes" (Comptes) and "Nouvelle
   campagne" (Warmup) — one consistent fold-away affordance. */
.addbox {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); margin-bottom: 16px;
}
.addbox > summary {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer; list-style: none;
  user-select: none; border-radius: var(--radius);
}
.addbox > summary::-webkit-details-marker { display: none; }
.addbox > summary:hover { background: var(--panel-2); }
.addbox-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14px; color: var(--text);
}
.addbox-title svg { color: var(--accent); }
/* CSS-border caret — one consistent disclosure affordance across the app. */
.addbox-chev {
  margin-left: auto; width: 7px; height: 7px; flex-shrink: 0;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg); transition: transform .2s ease;
}
.addbox[open] > summary .addbox-chev { transform: rotate(225deg); }
.addbox[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.addbox > .page-grid, .addbox-body { padding: 0 16px 16px; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .page-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { width: 68px; }
  .sidebar .brand-text,
  .sidebar .section-label,
  .sidebar .nav-text,
  .sidebar .logout-text { display: none; }
  .brand { justify-content: center; padding: 16px 8px; }
  .nav-link { justify-content: center; padding: 10px; }
  .sidebar-foot .btn { justify-content: center; }
  .content { padding: 20px 16px 40px; }
  .topbar { padding: 16px 20px; }
}

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
}
