/* ==========================================================================
   Console Mesh / Flotte — AllEyes Resilient (Cryptops)
   Charte reprise de cryptops.fr : Inter (texte), Space Grotesk (titres/marque),
   JetBrains Mono (données/techniques), fond quasi noir, gris zinc, aucune
   couleur vive hors badges de statut sémantiques.
   ========================================================================== */

:root {
  /* ---- fond & surfaces (zinc, comme cryptops.fr) ---- */
  --bg: #0a0a0a;
  --surface: #111113;
  --surface-2: #17181b;
  --surface-3: #1d1f23;

  /* ---- texte ---- */
  --fg-primary: #fafafa;
  --fg-secondary: #e4e4e7;
  --fg-muted: #a1a1aa;
  --fg-faint: #71717a;

  /* ---- bordures ---- */
  --line-subtle: rgba(255, 255, 255, 0.08);
  --line-default: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.24);

  /* ---- accent monochrome (inversion noir/blanc, comme le site) ---- */
  --accent: #fafafa;
  --accent-ink: #0a0a0a;
  --accent-dim: rgba(255, 255, 255, 0.08);
  --accent-dim-hover: rgba(255, 255, 255, 0.14);

  /* ---- statuts sémantiques ---- */
  --ok: #4ade80;
  --ok-dim: rgba(74, 222, 128, 0.12);
  --warn: #facc15;
  --warn-dim: rgba(250, 204, 21, 0.12);
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.12);
  --muted-badge: rgba(161, 161, 170, 0.14);

  /* ---- rayons (cartes rondes, boutons/inputs un peu moins, comme cryptops.fr) ---- */
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 7px;

  --font-ui: "Inter", "Noto Sans JP", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", "Inter", "Noto Sans JP", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Noto Sans JP", ui-monospace, Menlo, Consolas, monospace;

  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-pop: 0 18px 48px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg-secondary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--fg-primary); text-decoration: none; }
code, .mono { font-family: var(--font-mono); }

.hidden { display: none !important; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

::selection { background: rgba(255,255,255,0.2); }

/* scrollbars, discrets */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   Fond en grille, discret — repris du site (ds-bg-grid)
   ========================================================================== */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse 80% 55% at 50% 0%, black 0%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 55% at 50% 0%, black 0%, transparent 75%);
}

/* ==========================================================================
   Écran de connexion
   ========================================================================== */
#login-screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1;
}

.login-wrap {
  width: 100%;
  max-width: 408px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-mark {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 28px;
}
.login-mark svg { width: 30px; height: 30px; flex: none; }
.login-mark .wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--fg-primary);
}
.login-mark .divider {
  width: 1px;
  height: 18px;
  background: var(--line-strong);
}
.login-mark .suite {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
}

.login-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-default);
  border-radius: var(--radius-lg);
  padding: 30px 28px 26px;
  box-shadow: var(--shadow-card);
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--fg-primary);
  letter-spacing: -0.01em;
}

.login-card .subtitle {
  color: var(--fg-muted);
  margin: 0 0 22px;
  font-size: 12.5px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input, .field select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line-default);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--fg-primary);
  font-size: 14px;
  font-family: var(--font-ui);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input::placeholder { color: var(--fg-faint); }
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}
.field input[id="f-totp"] { font-family: var(--font-mono); letter-spacing: 0.08em; }

.field-hint {
  font-size: 11px;
  color: var(--fg-faint);
  margin-top: 5px;
}

button { cursor: pointer; font-family: inherit; border: none; }

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--accent-dim);
  border: 1px solid var(--line-default);
  color: var(--fg-primary);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: var(--accent-dim-hover); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: #fff; border-color: #fff; }

.btn-block { width: 100%; }

.btn-danger {
  background: var(--danger-dim);
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.22); border-color: var(--danger); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line-default);
  color: var(--fg-muted);
}
.btn-ghost:hover { border-color: var(--line-strong); color: var(--fg-primary); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.btn-icon { width: 16px; height: 16px; flex: none; }

/* spinner inline dans un bouton en chargement */
.btn .spinner {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  opacity: 0.6;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn-label { opacity: 0.75; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-box, .ok-box, .info-box {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border-radius: var(--radius-md);
  padding: 11px 13px;
  font-size: 12.5px;
  margin-bottom: 16px;
  line-height: 1.45;
}
.error-box { background: rgba(248, 113, 113, 0.08); border: 1px solid rgba(248, 113, 113, 0.3); color: #fecaca; }
.ok-box { background: rgba(74, 222, 128, 0.08); border: 1px solid rgba(74, 222, 128, 0.3); color: #bbf7d0; }
.info-box { background: var(--surface-2); border: 1px solid var(--line-default); color: var(--fg-muted); }

.hint {
  font-size: 11px;
  color: var(--fg-faint);
  margin-top: 18px;
  line-height: 1.6;
  text-align: center;
}
.hint strong { color: var(--fg-muted); }
.hint code {
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10.5px;
}

.login-footer {
  margin-top: 26px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
  text-align: center;
}
.login-footer .sep { margin: 0 8px; opacity: 0.5; }

/* ==========================================================================
   App shell
   ========================================================================== */
#app-screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  z-index: 1;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-default);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .brand-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--fg-primary);
}
.topbar .brand-mini svg { width: 20px; height: 20px; }
.menu-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--line-default);
  border-radius: var(--radius-sm);
  color: var(--fg-secondary);
}
.menu-btn svg { width: 18px; height: 18px; }

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 35;
}

.sidebar {
  width: 236px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line-default);
  padding: 22px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--line-subtle);
  margin-bottom: 14px;
}
.sidebar .brand svg { width: 26px; height: 26px; flex: none; }
.sidebar .brand .name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--fg-primary);
  line-height: 1.2;
}
.sidebar .brand .tag {
  color: var(--fg-faint);
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-section-label {
  padding: 0 20px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 20px;
  margin: 1px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.nav-item:hover { color: var(--fg-primary); background: rgba(255,255,255,0.04); }
.nav-item.active {
  color: var(--fg-primary);
  background: var(--accent-dim);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px 0;
  border-top: 1px solid var(--line-subtle);
}
.sidebar-footer .who {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  margin-bottom: 12px;
}
.sidebar-footer .who-avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--line-default);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  color: var(--fg-primary);
}
.sidebar-footer .who-text { min-width: 0; overflow: hidden; }
.sidebar-footer .who .email {
  color: var(--fg-primary);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}
.sidebar-footer .who .role {
  color: var(--fg-faint);
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.garance-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-default);
  padding: 10px 28px;
  font-size: 12px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}
.garance-banner strong { color: var(--fg-secondary); font-weight: 600; }
.garance-banner .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);
  flex: none;
  animation: pulse-dot 2.4s ease-in-out infinite;
}
.garance-banner .sep { margin: 0 4px; color: var(--line-strong); }
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18); }
  50% { box-shadow: 0 0 0 5px rgba(74, 222, 128, 0.08); }
}

.content {
  padding: 28px 32px 40px;
  flex: 1;
  overflow: auto;
}

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.content h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 5px;
  color: var(--fg-primary);
  letter-spacing: -0.01em;
}
.content .subtitle {
  color: var(--fg-faint);
  font-size: 12.5px;
  margin: 0;
  font-family: var(--font-mono);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-subtle);
}
.panel-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-secondary);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  color: var(--fg-faint);
  font-weight: 600;
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line-subtle);
  background: var(--surface-2);
}
tbody td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-subtle);
  vertical-align: middle;
  color: var(--fg-secondary);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.025); }

.mono { font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-family: var(--font-mono);
}
.badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge-ok { background: var(--ok-dim); color: var(--ok); }
.badge-warn { background: var(--warn-dim); color: var(--warn); }
.badge-danger { background: var(--danger-dim); color: var(--danger); }
.badge-muted { background: var(--muted-badge); color: var(--fg-muted); }

.empty-state, .stub-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--fg-faint);
  font-size: 13px;
}
.empty-state .spinner-lg {
  width: 20px; height: 20px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
.stub-state {
  color: var(--warn);
  background: rgba(250, 204, 21, 0.045);
  text-align: left;
  padding: 20px 22px;
  line-height: 1.6;
}
.stub-state code {
  background: rgba(255,255,255,0.07);
  color: var(--fg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11.5px;
}

/* ---- cartes de nœuds Mesh ---- */
.node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  padding: 16px;
}
.node-card {
  background: var(--surface-2);
  border: 1px solid var(--line-default);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: border-color 0.15s ease;
}
.node-card:hover { border-color: var(--line-strong); }
.node-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.node-card-head .node-host {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--fg-primary);
  word-break: break-word;
}
.node-card-head .node-id {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-faint);
  margin-top: 2px;
  word-break: break-all;
}
.node-fields { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.node-field { display: flex; flex-direction: column; gap: 2px; }
.node-field .k {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
}
.node-field .v {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-secondary);
  word-break: break-all;
}
.node-card-actions { display: flex; justify-content: flex-end; border-top: 1px solid var(--line-subtle); padding-top: 12px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 18px;
}
.form-grid .field { margin-bottom: 0; }
.form-grid .field.span-2 { grid-column: span 2; }
.form-actions { padding: 0 18px 18px; display: flex; justify-content: flex-end; }

footer.app-footer {
  padding: 16px 32px 28px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
  text-align: center;
}
footer.app-footer .sep { margin: 0 8px; opacity: 0.5; }

/* ---- toasts ---- */
#toast-root {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100vw - 32px);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface-3);
  border: 1px solid var(--line-default);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 12.5px;
  max-width: 360px;
  box-shadow: var(--shadow-pop);
  animation: toast-in 0.18s ease-out;
}
.toast::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-top: 4px;
  flex: none;
  background: var(--fg-muted);
}
.toast.ok { border-color: rgba(74,222,128,0.4); }
.toast.ok::before { background: var(--ok); }
.toast.err { border-color: rgba(248,113,113,0.4); }
.toast.err::before { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   Responsive — mobile
   ========================================================================== */
@media (max-width: 860px) {
  #app-screen { flex-direction: column; }

  .topbar { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 40;
    box-shadow: var(--shadow-pop);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open #sidebar-overlay { display: block; }

  .content { padding: 20px 16px 32px; }
  .garance-banner { padding: 9px 16px; font-size: 11px; }
  .form-grid { grid-template-columns: 1fr 1fr; padding: 14px; }
  .form-grid .field.span-2 { grid-column: span 2; }
  .node-grid { grid-template-columns: 1fr; padding: 12px; }
  .panel-header { padding: 12px 14px; }
  table { font-size: 12px; }
  thead th, tbody td { padding: 9px 12px; }
  footer.app-footer { padding: 14px 16px 24px; }
}

@media (max-width: 480px) {
  .login-card { padding: 24px 18px 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .field.span-2 { grid-column: span 1; }
  .login-footer, footer.app-footer { white-space: normal; }
}
