/* ==========================================================================
   NetToolbox — design system
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, monospace;

  --r-xs: 6px;
  --r-sm: 9px;
  --r: 13px;
  --r-lg: 20px;
  --r-pill: 999px;

  --dur: 170ms;
  --dur-slow: 340ms;
  --ease: cubic-bezier(.32, .72, .28, 1);

  --nav-w: 244px;
  --topbar-h: 58px;
}

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080b11;
  --bg-tint:
    radial-gradient(1100px 580px at 12% -12%, rgba(77, 141, 255, .16), transparent 62%),
    radial-gradient(880px 520px at 102% -4%, rgba(34, 211, 238, .11), transparent 58%);
  --surface: #0f151e;
  --surface-2: #151d29;
  --surface-3: #1c2635;
  --border: #223047;
  --border-soft: #19222f;
  --text: #e8eef7;
  --text-dim: #a7b4c7;
  --text-mute: #6f7f95;
  --accent: #4d8dff;
  --accent-2: #22d3ee;
  --accent-ink: #04121f;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 28px -14px rgba(0, 0, 0, .8);
  --shadow-lg: 0 28px 70px -24px rgba(0, 0, 0, .9);
  --glass: rgba(11, 16, 23, .82);
  --track: #1b2534;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-tint:
    radial-gradient(1100px 580px at 12% -12%, rgba(77, 141, 255, .13), transparent 62%),
    radial-gradient(880px 520px at 102% -4%, rgba(34, 211, 238, .10), transparent 58%);
  --surface: #ffffff;
  --surface-2: #f5f8fc;
  --surface-3: #eaf0f8;
  --border: #d9e2ee;
  --border-soft: #e7edf5;
  --text: #0e1721;
  --text-dim: #48586c;
  --text-mute: #74849a;
  --accent: #2563eb;
  --accent-2: #0891b2;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --ok: #059669;
  --warn: #b45309;
  --bad: #dc2626;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 10px 26px -16px rgba(16, 32, 56, .32);
  --shadow-lg: 0 26px 60px -26px rgba(16, 32, 56, .38);
  --glass: rgba(255, 255, 255, .84);
  --track: #e4ebf4;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-2: #f5f8fc;
    --surface-3: #eaf0f8;
    --border: #d9e2ee;
    --border-soft: #e7edf5;
    --text: #0e1721;
    --text-dim: #48586c;
    --text-mute: #74849a;
    --accent: #2563eb;
    --accent-2: #0891b2;
    --accent-ink: #ffffff;
    --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
    --ok: #059669;
    --warn: #b45309;
    --bad: #dc2626;
    --glass: rgba(255, 255, 255, .84);
    --track: #e4ebf4;
  }
}

/* ==========================================================================
   Palettes (skins) — surchargent uniquement les couleurs d'accent ; tout le
   reste (surfaces, texte, --accent-soft calculé via color-mix) suit
   automatiquement.
   ========================================================================== */

:root[data-skin="ocean"][data-theme="dark"],
:root[data-theme="dark"]:not([data-skin]) { --accent: #4d8dff; --accent-2: #22d3ee; }
:root[data-skin="ocean"][data-theme="light"],
:root[data-theme="light"]:not([data-skin]) { --accent: #2563eb; --accent-2: #0891b2; }

:root[data-skin="violet"][data-theme="dark"] { --accent: #a78bfa; --accent-2: #f472b6; }
:root[data-skin="violet"][data-theme="light"] { --accent: #7c3aed; --accent-2: #db2777; }

:root[data-skin="emerald"][data-theme="dark"] { --accent: #34d399; --accent-2: #a3e635; }
:root[data-skin="emerald"][data-theme="light"] { --accent: #059669; --accent-2: #65a30d; }

:root[data-skin="amber"][data-theme="dark"] { --accent: #fbbf24; --accent-2: #fb923c; }
:root[data-skin="amber"][data-theme="light"] { --accent: #b45309; --accent-2: #c2410c; }

:root[data-skin="mono"][data-theme="dark"] { --accent: #cbd5e1; --accent-2: #94a3b8; --accent-ink: #0b1018; }
:root[data-skin="mono"][data-theme="light"] { --accent: #334155; --accent-2: #64748b; --accent-ink: #ffffff; }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  background-image: var(--bg-tint);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* --- Scrollbars ----------------------------------------------------------- */

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-pill); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-mute); background-clip: content-box; }

/* --- Topbar --------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  /* Sur un mobile à encoche/Dynamic Island, la zone sécurisée s'ajoute en
     plus de la hauteur nominale plutôt que de la rogner (box-sizing:
     border-box oblige), pour ne jamais passer sous le capteur. */
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 660;
  font-size: 15px;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent);
}
.brand-mark svg { width: 18px; height: 18px; }

.brand-sub {
  color: var(--text-mute);
  font-weight: 450;
  font-size: 12px;
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid var(--border);
}

.topbar-spacer { flex: 1; }

.icon-btn {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }
.icon-btn svg { width: 18px; height: 18px; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}
.avatar {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase;
}

#nav-toggle { display: none; }

/* --- Layout --------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  align-items: start;
}

.sidenav {
  position: sticky;
  top: calc(var(--topbar-h) + env(safe-area-inset-top));
  height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top));
  overflow-y: auto;
  padding: 18px 12px 24px;
  padding-left: max(12px, env(safe-area-inset-left));
  border-right: 1px solid var(--border-soft);
}

.nav-label {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 0 10px;
  margin: 14px 0 6px;
}
.nav-label:first-child { margin-top: 0; }

.nav-item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13.5px;
  font-weight: 520;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  translate: 0 -50%;
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 44;
  background: rgba(2, 6, 12, .55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease);
}
.backdrop.show { opacity: 1; pointer-events: auto; }

.content {
  min-width: 0;
  padding: 26px 28px 64px;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* --- Panels --------------------------------------------------------------- */

.panel { display: none; max-width: 1000px; }
.panel.active { display: block; }

.panel-head { margin-bottom: 20px; animation: fadeUp var(--dur-slow) var(--ease) both; }
.panel-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 680;
  letter-spacing: -.022em;
}
.panel-head p {
  margin: 5px 0 0;
  color: var(--text-mute);
  font-size: 13.5px;
  max-width: 68ch;
}

/* --- Cards ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  animation: fadeUp var(--dur-slow) var(--ease) both;
}
.panel.active .card:nth-child(2) { animation-delay: 40ms; }
.panel.active .card:nth-child(3) { animation-delay: 80ms; }
.panel.active .card:nth-child(4) { animation-delay: 120ms; }
.panel.active .card:nth-child(5) { animation-delay: 160ms; }

.card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 4px;
}
.card-head h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 640;
  letter-spacing: -.01em;
}
.card-head .dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.card > .hint {
  margin: 0 0 14px;
  color: var(--text-mute);
  font-size: 12.5px;
}

/* --- Forms ---------------------------------------------------------------- */

.form {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}
.form.stack { flex-direction: column; align-items: stretch; }

input[type=text], input[type=number], input[type=password], select, textarea {
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  min-height: 40px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }

input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
  background: var(--surface);
}

.grow { flex: 1 1 220px; min-width: 0; }
.w-sm { width: 92px; flex: none; }
.w-md { width: 150px; flex: none; }

textarea {
  width: 100%;
  min-height: 96px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  padding: 0 2px;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* Segmented control (IPv4 / IPv6) */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  flex: none;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--text-mute);
  font: inherit;
  font-size: 12.5px;
  font-weight: 620;
  padding: 6px 13px;
  min-height: 32px;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}

/* --- Buttons -------------------------------------------------------------- */

button {
  font-family: inherit;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  font-size: 13.5px;
  font-weight: 640;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), filter var(--dur) var(--ease);
  box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent) 75%, transparent); }
.btn:active { transform: translateY(0) scale(.985); }
.btn:disabled { opacity: .6; cursor: progress; transform: none; filter: none; }

.btn.ghost {
  background: var(--surface-2);
  color: var(--text-dim);
  border-color: var(--border);
  box-shadow: none;
}
.btn.ghost:hover { color: var(--text); background: var(--surface-3); box-shadow: none; }

.btn.danger {
  background: transparent;
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
  box-shadow: none;
}
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); box-shadow: none; }

.btn.sm { min-height: 32px; padding: 5px 12px; font-size: 12.5px; }

.btn svg { width: 16px; height: 16px; }

/* --- Results -------------------------------------------------------------- */

.result:not(:empty) {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  animation: fadeUp var(--dur-slow) var(--ease) both;
}

.empty {
  color: var(--text-mute);
  font-size: 13px;
  padding: 6px 0;
}

.error-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--bad) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 28%, transparent);
  color: var(--bad);
  font-size: 13px;
}

/* Stat tiles */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}
.stat {
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
}
.stat dt {
  font-size: 10.5px;
  font-weight: 620;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 3px;
}
.stat dd {
  margin: 0;
  font-size: 19px;
  font-weight: 660;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.stat dd small { font-size: 12px; font-weight: 500; color: var(--text-mute); }
.stat.ok dd { color: var(--ok); }
.stat.warn dd { color: var(--warn); }
.stat.bad dd { color: var(--bad); }

/* Mise en évidence forte (ex: jumbo frame) — fond teinté + bordure, pas
   seulement le texte coloré, pour vraiment sauter aux yeux dans la grille. */
.stat.accent {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.stat.accent dd { color: var(--accent); }

/* Key/value list */
.kv { display: grid; gap: 1px; background: var(--border-soft); border: 1px solid var(--border-soft); border-radius: var(--r-sm); overflow: hidden; }
.kv-row { display: grid; grid-template-columns: minmax(140px, 30%) 1fr; gap: 14px; padding: 9px 13px; background: var(--surface); font-size: 13.5px; }
.kv-row dt { color: var(--text-mute); font-size: 12.5px; }
.kv-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv-row dd.mono { font-family: var(--font-mono); font-size: 12.5px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 640;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.badge.warn { background: color-mix(in srgb, var(--warn) 17%, transparent); color: var(--warn); }
.badge.neutral { background: var(--surface-3); color: var(--text-dim); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.badge-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 13px; }

.badge.as-link {
  border: 0;
  cursor: pointer;
  font: inherit;
  letter-spacing: .01em;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.badge.as-link:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); transform: translateY(-1px); }
.badge.as-link:active { transform: translateY(0); }

/* Latency bars */
.bars { display: grid; gap: 6px; }
.bar-row {
  display: grid;
  grid-template-columns: 46px 1fr 72px;
  align-items: center;
  gap: 11px;
  font-size: 12.5px;
}
.bar-row .lbl { color: var(--text-mute); font-family: var(--font-mono); font-size: 11.5px; }
.bar-track { height: 7px; border-radius: var(--r-pill); background: var(--track); overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform-origin: left;
  animation: growBar 620ms var(--ease) both;
}
.bar-fill.warn { background: linear-gradient(90deg, var(--warn), #fb923c); }
.bar-fill.bad { background: linear-gradient(90deg, var(--bad), #fb7185); }
.bar-row .val { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Hop list (traceroute) */
.hops { display: grid; gap: 5px; }
.hop {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  animation: fadeUp 300ms var(--ease) both;
}
.hop.timeout { opacity: .6; border-style: dashed; }
.hop-n {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-mute);
  font-size: 11.5px; font-weight: 660;
  font-variant-numeric: tabular-nums;
}
.hop-main { min-width: 0; }
.hop-ip {
  font-family: var(--font-mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.hop-as {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-mute);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.hop-rtt {
  display: grid;
  gap: 4px;
  justify-items: end;
  width: 108px;
}
.hop-rtt .v { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.hop-rtt .bar-track { width: 100%; height: 4px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--r-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  position: sticky; top: 0;
  text-align: left;
  padding: 9px 13px;
  background: var(--surface-2);
  color: var(--text-mute);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-soft);
}
tbody td { padding: 9px 13px; border-bottom: 1px solid var(--border-soft); vertical-align: top; overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--dur) var(--ease); }
tbody tr:hover td { background: var(--surface-2); }
td.mono, .mono { font-family: var(--font-mono); font-size: 12.5px; }
td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* Code block */
.code {
  margin: 0;
  padding: 13px 15px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 380px;
  overflow: auto;
}

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* --- Monitoring ----------------------------------------------------------- */

.mon-card {
  padding: 14px 15px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  margin-bottom: 10px;
  animation: fadeUp var(--dur-slow) var(--ease) both;
}
.mon-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.mon-name { font-weight: 620; font-family: var(--font-mono); font-size: 13.5px; }
.mon-meta { color: var(--text-mute); font-size: 12px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mon-actions { display: flex; gap: 6px; flex: none; }
.mon-chart { margin-top: 12px; }
.mon-chart svg { display: block; width: 100%; height: 68px; overflow: visible; }

.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 70%, transparent);
  animation: pulse 2.2s infinite;
  flex: none;
}
.live-dot.off { background: var(--text-mute); animation: none; box-shadow: none; }

/* --- List items ----------------------------------------------------------- */

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  margin-bottom: 7px;
  font-size: 13.5px;
  transition: border-color var(--dur) var(--ease);
}
.list-item:hover { border-color: var(--border); }
.list-item .t { font-family: var(--font-mono); font-weight: 600; }
.list-item .l { color: var(--text-mute); font-size: 12.5px; }

/* --- Toasts --------------------------------------------------------------- */

.toasts {
  position: fixed;
  z-index: 60;
  bottom: max(18px, env(safe-area-inset-bottom));
  right: 18px;
  display: grid;
  gap: 9px;
  max-width: min(340px, calc(100vw - 36px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: toastIn 280ms var(--ease) both;
}
.toast.out { animation: toastOut 220ms var(--ease) both; }
.toast .ic { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--accent); }
.toast.ok .ic { background: var(--ok); }
.toast.bad .ic { background: var(--bad); }

/* --- Spinner -------------------------------------------------------------- */

.spinner {
  width: 15px; height: 15px;
  border: 2px solid color-mix(in srgb, currentColor 28%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .68s linear infinite;
}

.skeleton {
  height: 13px;
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  margin-bottom: 8px;
}
.skeleton:nth-child(2) { width: 84%; }
.skeleton:nth-child(3) { width: 62%; }

/* --- Login ---------------------------------------------------------------- */

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}
.login-box {
  width: min(100%, 372px);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 34px 30px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 460ms var(--ease) both;
}
.login-box .brand { justify-content: center; font-size: 17px; margin-bottom: 6px; }
.login-box .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
.login-box .brand-mark svg { width: 21px; height: 21px; }
.login-tag { text-align: center; color: var(--text-mute); font-size: 13px; margin: 0 0 26px; }
.login-box .field { margin-bottom: 11px; }
.login-box input { width: 100%; }
.login-box .btn { width: 100%; margin-top: 8px; }
.login-box .error-msg { margin-top: 14px; }
.login-foot { margin-top: 22px; text-align: center; color: var(--text-mute); font-size: 11.5px; }

/* --- Animations ----------------------------------------------------------- */

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes growBar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 65%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes drawLine { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }

/* ==========================================================================
   Responsive — tablet & mobile
   ========================================================================== */

@media (max-width: 1000px) {
  :root { --nav-w: 216px; }
  .content { padding: 22px 20px 56px; }
}

@media (max-width: 860px) {
  #nav-toggle { display: grid; }
  .brand-sub { display: none; }

  .layout { grid-template-columns: minmax(0, 1fr); }

  .sidenav {
    position: fixed;
    z-index: 45;
    top: 0;
    left: 0;
    bottom: 0;
    width: 268px;
    height: 100dvh;
    padding-top: max(16px, env(safe-area-inset-top));
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    translate: -102% 0;
    transition: translate var(--dur-slow) var(--ease);
    overscroll-behavior: contain;
  }
  .sidenav.open { translate: 0 0; }

  .nav-item { padding: 12px 13px; font-size: 14.5px; }
  .nav-item.active::before { left: -12px; }

  .content { padding: 20px 16px 56px; }
  .panel-head h1 { font-size: 19.5px; }
  .card { padding: 15px; border-radius: var(--r-sm); }

  .user-chip span:not(.avatar) { display: none; }
  .user-chip { padding: 5px; }
}

@media (max-width: 620px) {
  body { font-size: 15px; }

  .content { padding: 16px 12px 48px; }
  .card { padding: 14px 13px; }

  /* Full-width controls, comfortable touch targets */
  .form { gap: 8px; }
  .form > input[type=text], .form > textarea, .form > select { flex: 1 1 100%; width: 100%; min-height: 44px; }
  .form > .btn { flex: 1 1 100%; min-height: 44px; }
  .form > .seg { flex: 1 1 auto; }
  .form > .seg button { flex: 1; min-height: 36px; }
  .w-sm { width: 88px; }
  .w-md { flex: 1 1 130px; width: auto; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat dd { font-size: 17px; }

  /* Key/value stacks */
  .kv-row { grid-template-columns: 1fr; gap: 2px; padding: 10px 12px; }
  .kv-row dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }

  /* Tables become cards */
  .table-wrap { border: 0; border-radius: 0; overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr {
    padding: 11px 13px;
    margin-bottom: 8px;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    background: var(--surface-2);
  }
  tbody tr:hover td { background: transparent; }
  tbody td {
    display: grid;
    grid-template-columns: 40% 1fr;
    gap: 10px;
    padding: 4px 0;
    border: 0;
    font-size: 13.5px;
  }
  tbody td::before {
    content: attr(data-label);
    color: var(--text-mute);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    align-self: center;
  }
  td.num { text-align: left; }

  /* Hops */
  .hop { grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 10px; }
  .hop-rtt { grid-column: 2; width: 100%; justify-items: stretch; }
  .hop-rtt .v { text-align: right; }

  .bar-row { grid-template-columns: 40px 1fr 62px; gap: 8px; }

  .mon-top { flex-direction: column; align-items: stretch; }
  .mon-actions { justify-content: flex-end; }
  .mon-actions .btn { flex: 1; }

  .list-item { flex-wrap: wrap; }

  .toasts { right: 12px; left: 12px; max-width: none; }
}

@media (hover: none) {
  .btn:hover, .icon-btn:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .sidenav { transition: none; }
}

/* ==========================================================================
   Comptes & administration
   ========================================================================== */

.hidden { display: none !important; }

/* Overlay bloquant (changement de mot de passe obligatoire) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  background: rgba(3, 7, 13, .74);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeUp 240ms var(--ease) both;
  overflow-y: auto;
}
.modal {
  width: min(100%, 430px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}
.modal h2 { margin: 0 0 6px; font-size: 17px; font-weight: 660; }
.modal p.hint { margin: 0 0 18px; }
.modal .field { margin-bottom: 10px; }
.modal input { width: 100%; }
.modal .btn { width: 100%; margin-top: 8px; }

/* Secret affiché une seule fois */
.secret {
  margin-top: 14px;
  padding: 15px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--warn) 9%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--warn) 34%, transparent);
  animation: fadeUp var(--dur-slow) var(--ease) both;
}
.secret .t {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 640;
  color: var(--warn);
  margin-bottom: 9px;
}
.secret .v {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--r-xs);
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
  user-select: all;
}
.secret .v span { flex: 1; min-width: 0; }
.secret .n { margin: 9px 0 0; font-size: 12px; color: var(--text-dim); }

/* Liste des comptes */
.user-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 13px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  margin-bottom: 8px;
  animation: fadeUp var(--dur-slow) var(--ease) both;
}
.user-id { display: flex; align-items: center; gap: 11px; flex: 1 1 210px; min-width: 0; }
.user-av {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  font-weight: 700; font-size: 13.5px; text-transform: uppercase;
}
.user-name { font-weight: 620; font-size: 14px; }
.user-mail { color: var(--text-mute); font-size: 12.5px; overflow-wrap: anywhere; }
.user-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.user-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

.pw-meter { height: 4px; border-radius: var(--r-pill); background: var(--track); overflow: hidden; margin-top: 7px; }
.pw-meter i { display: block; height: 100%; width: 0; border-radius: var(--r-pill); transition: width var(--dur-slow) var(--ease), background var(--dur) var(--ease); }

.login-link {
  display: block;
  margin-top: 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-mute);
  background: none;
  border: 0;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
}
.login-link:hover { color: var(--accent); }

@media (max-width: 620px) {
  .modal { padding: 22px 18px; }
  .user-acts { margin-left: 0; width: 100%; }
  .user-acts .btn { flex: 1; }
}

/* ==========================================================================
   Panneau Réglages
   ========================================================================== */

.skin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.skin-swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 14px 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1.5px solid var(--border-soft);
  cursor: pointer;
  font: inherit;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 560;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.skin-swatch:hover { border-color: var(--border); transform: translateY(-1px); }
.skin-swatch.active {
  border-color: var(--sw-a);
  color: var(--text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sw-a) 18%, transparent);
}
.skin-swatch .dots {
  display: flex;
  gap: 5px;
}
.skin-swatch .dots i {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: block;
}
.skin-swatch .dots i:first-child { background: var(--sw-a); margin-right: -8px; box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--sw-a) 60%, transparent); }
.skin-swatch .dots i:last-child { background: var(--sw-b); }
.skin-swatch.active::after {
  content: "";
  position: absolute;
  top: 8px; right: 8px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--sw-a);
  box-shadow: 0 0 0 2px var(--surface-2);
}

.lang-grid, .theme-grid {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}
.opt-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1.5px solid var(--border-soft);
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  font-weight: 560;
  color: var(--text-dim);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.opt-card:hover { border-color: var(--border); color: var(--text); transform: translateY(-1px); }
.opt-card.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.opt-card .flag { font-size: 17px; line-height: 1; }
.opt-card .ico { width: 17px; height: 17px; flex: none; }

@media (max-width: 620px) {
  .skin-grid { grid-template-columns: repeat(3, 1fr); }
  .lang-grid, .theme-grid { flex-direction: column; }
  .opt-card { width: 100%; }
}

/* Sélecteur de langue compact (pages de connexion/réinitialisation) */
.opt-card.sm {
  padding: 8px 12px;
  font-size: 18px;
  line-height: 1;
}
.opt-card.sm .flag { font-size: 18px; }

/* ==========================================================================
   Traceroute — chemin visuel
   ========================================================================== */

.path-wrap { margin-top: 4px; }
.path-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  border-radius: var(--r-sm);
}
.path-scroll svg { display: block; min-width: 100%; }

.path-lbl {
  font-size: 10px;
  fill: var(--text-mute);
  font-family: var(--font-mono);
}
.path-lbl-strong {
  font-size: 10.5px;
  fill: var(--text);
  font-weight: 700;
  font-family: var(--font-sans);
}
.path-as {
  font-size: 9.5px;
  fill: var(--accent);
  font-weight: 700;
}
.path-node { transition: r var(--dur) var(--ease); }
.path-node-g:hover .path-node { r: 8.5; }

.path-line-draw { animation: drawLine 1.15s var(--ease) both; }

@media (max-width: 620px) {
  .path-lbl, .path-lbl-strong, .path-as { font-size: 11px; }
}

/* ==========================================================================
   Export PDF (impression navigateur)
   ========================================================================== */

.export-btn { margin-left: auto; }
.export-btn svg { width: 14px; height: 14px; }

#print-report { display: none; }

.print-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 2px solid #111;
  padding-bottom: 12px;
  margin-bottom: 4px;
}
.print-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: #111; }
.print-brand .brand-mark { width: 26px; height: 26px; border-radius: 7px; background: #111 !important; color: #fff !important; }
.print-title { font-size: 13px; color: #333; text-align: right; font-weight: 600; }
.print-meta { font-size: 11px; color: #555; margin: 6px 0 18px; }
.print-h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #555;
  margin: 22px 0 9px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 5px;
}
.print-footer { margin-top: 28px; padding-top: 10px; border-top: 1px solid #ddd; font-size: 10px; color: #777; }

@media print {
  @page { margin: 14mm 12mm; }

  body * { visibility: hidden !important; }
  #print-report, #print-report * { visibility: visible !important; }
  #print-report {
    display: block !important;
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 0;
    background: #fff;
    color: #111318;
    font-size: 12px;
  }

  /* Palette imprimable forcée, quel que soit le thème/skin actif à l'écran */
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #f6f8fb; --surface-3: #eef1f6;
    --border: #d7dee8; --border-soft: #e7ecf3;
    --text: #111318; --text-dim: #3a4250; --text-mute: #5c6674;
    --shadow: none; --shadow-lg: none; --glass: #fff;
  }

  .path-scroll { overflow: visible !important; }
  #print-report svg { width: 100% !important; height: auto !important; max-width: 100%; }
  .table-wrap { overflow: visible !important; border: 1px solid var(--border-soft); }
  .btn, .icon-btn, .spinner, .skeleton { display: none !important; }
  a { text-decoration: underline; color: #111; }
}

/* ==========================================================================
   Traceroute — carte du monde
   ========================================================================== */

.worldmap-wrap {
  margin-top: 4px;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.worldmap-wrap svg { display: block; width: 100%; height: auto; }
.worldmap-land { fill: var(--surface-3); stroke: var(--border); stroke-width: 0.6; }
.worldmap-line { fill: none; stroke: url(#trMapGrad); stroke-width: 1.4; stroke-linecap: round; opacity: .85; }
.worldmap-marker { stroke: var(--surface); stroke-width: 1.2; }
.worldmap-marker.endpoint { stroke-width: 2; }
