/* ═══════════════════════════════════════════════════════════
   DashSPIE — dashboard personnel (app séparée, hors moteur
   immersif). Reprend les tokens visuels du site (accent, dark).
   ═══════════════════════════════════════════════════════════ */

:root {
  --ink-rgb: 242, 241, 236;
  --bone: #141311;
  --ink: #f2f1ec;
  --ash: #8f938f;
  --white: #201f1c;
  --surface: #1a1915;
  --lime: #e6142c;
  --lime-ink: #ffffff;
  --sans: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --mono: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { background: var(--bone); }
body {
  background: var(--bone);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; }
button, input { font-family: inherit; }

.mono { font-family: var(--mono); letter-spacing: 0.04em; }

/* ─── garde (pas de session) ─── */
.guard {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
}
.guard-text { color: var(--ash); font-size: 15px; }
.guard-text a { color: var(--lime); text-decoration: none; margin-left: 6px; }

/* ─── structure ─── */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.app[hidden], .guard[hidden] { display: none; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 16px 28px;
  border-bottom: 1px solid rgba(var(--ink-rgb), 0.1);
  flex-wrap: wrap;
}
.topbar-brand {
  font-family: var(--sans); font-weight: 500; font-size: 18px;
  text-decoration: none; color: var(--ink);
}
.topbar-tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar-tab {
  border: none; background: transparent; cursor: pointer;
  padding: 9px 16px; border-radius: 999px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ash);
  transition: background .2s ease, color .2s ease;
}
.topbar-tab:hover { color: var(--ink); }
.topbar-tab.is-active { background: var(--white); color: var(--ink); }

.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-email { font-family: var(--mono); font-size: 12px; color: var(--ash); }
.topbar-role {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  background: var(--lime); color: var(--lime-ink);
  padding: 3px 8px; border-radius: 999px;
}
.topbar-logout {
  border: 1px solid rgba(var(--ink-rgb), 0.2); background: transparent;
  color: var(--ash); cursor: pointer;
  padding: 7px 14px; border-radius: 999px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
  transition: border-color .2s ease, color .2s ease;
}
.topbar-logout:hover { border-color: var(--lime); color: var(--ink); }

.view-wrap { flex: 1; padding: 32px 28px 64px; max-width: 1100px; width: 100%; margin: 0 auto; }
.view[hidden] { display: none; }

.view-head { margin-bottom: 24px; }
.view-head h1 { font-size: 26px; font-weight: 500; letter-spacing: -0.01em; }
.view-sub { color: var(--ash); font-size: 13px; margin-top: 6px; }

.view-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.btn {
  border: none; cursor: pointer; border-radius: 999px;
  padding: 11px 20px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase;
  transition: transform .2s ease, opacity .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn-accent { background: var(--lime); color: var(--lime-ink); }
.btn-ghost { background: var(--white); color: var(--ink); }
.btn-danger { background: transparent; color: var(--ash); border: 1px solid rgba(var(--ink-rgb), 0.18); }
.btn-danger:hover { color: var(--lime); border-color: var(--lime); }

/* ─── grille de modules ─── */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px; margin-top: 8px;
}
.card {
  position: relative;
  background: var(--white);
  border-radius: 14px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 28px;
  text-decoration: none; color: var(--ink);
  min-height: 120px;
  transition: transform .2s ease;
}
.card:hover { transform: translateY(-3px); }
.card-swatch {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  color: var(--lime-ink);
}
.card-title { font-size: 15px; font-weight: 500; line-height: 1.3; }
.card-url { font-family: var(--mono); font-size: 10px; color: var(--ash); word-break: break-all; margin-top: 2px; }
.card-remove {
  position: absolute; top: 10px; right: 10px;
  width: 24px; height: 24px; border-radius: 50%;
  border: none; background: rgba(var(--ink-rgb), 0.08); color: var(--ash);
  cursor: pointer; font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s ease, background .2s ease, color .2s ease;
}
.card:hover .card-remove { opacity: 1; }
.card-remove:hover { background: var(--lime); color: var(--lime-ink); }
.card-badge {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ash); align-self: flex-start;
}

.empty-hint { color: var(--ash); font-size: 13px; margin-top: 24px; }

/* ─── formulaires inline (admin) ─── */
.inline-form {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 24px; padding: 16px; background: var(--white); border-radius: 14px;
}
.field {
  background: var(--bone);
  border: 1px solid rgba(var(--ink-rgb), 0.14);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
}
.field:focus { border-color: var(--lime); }
.field-url { flex: 1; min-width: 180px; }

.swatches { display: flex; gap: 6px; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
}
.swatch.is-selected { border-color: var(--ink); }

/* ─── tableaux (codes, comptes) ─── */
.table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: 14px; overflow: hidden; }
.table th, .table td {
  text-align: left; padding: 12px 16px; font-size: 13px;
  border-bottom: 1px solid rgba(var(--ink-rgb), 0.08);
}
.table th { font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ash); }
.table td.mono { color: var(--ash); }
.table tr:last-child td { border-bottom: none; }

/* ─── modales ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--white); border-radius: 16px; padding: 26px;
  width: min(440px, 100%);
  max-height: 80vh; overflow-y: auto;
}
.modal h2 { font-size: 18px; font-weight: 500; margin-bottom: 16px; }
.modal form { display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.modal-msg { font-family: var(--mono); font-size: 11px; color: var(--lime); min-height: 14px; }

.modal-sm { width: min(380px, 100%); }
.modal-sm p { font-size: 14px; line-height: 1.5; }
.btn-danger-solid { background: var(--lime); color: var(--lime-ink); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--white); color: var(--ink);
  padding: 12px 20px; border-radius: 999px;
  font-size: 13px; z-index: 900;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  border: 1px solid rgba(var(--ink-rgb), 0.12);
}
.toast[hidden] { display: none; }
.toast.is-error { border-color: var(--lime); color: var(--lime); }

.catalog-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.catalog-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: var(--bone); border-radius: 10px;
}
.catalog-row .card-swatch { width: 28px; height: 28px; font-size: 11px; flex-shrink: 0; }
.catalog-row-title { flex: 1; font-size: 13px; }
.catalog-row-added { font-family: var(--mono); font-size: 10px; color: var(--ash); text-transform: uppercase; }

@media (max-width: 640px) {
  .topbar { padding: 14px 16px; }
  .topbar-tabs { order: 3; width: 100%; }
  .view-wrap { padding: 24px 16px 48px; }
}
