/* ==========================================================================
   IP Manager — feuille de style
   Thème sombre unique, direction « console premium » : surfaces en couches,
   hairlines, accent indigo, chiffres tabulaires.
   CSS pur, aucune police distante, aucun script (CSP `style-src 'self'`).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Jetons
   -------------------------------------------------------------------------- */

:root {
  color-scheme: dark;

  /* fonds */
  --canvas: #080b11;
  --surface: #101724;
  --surface-2: #141c2b;
  --surface-3: #1a2333;
  --surface-in: #131a28;
  --field: #0c1220;
  --header: rgba(9, 12, 18, .82);

  /* traits */
  --line: #222c3e;
  --line-soft: #1b2433;
  --line-strong: #33415a;

  /* texte */
  --ink: #e9eef8;
  --ink-2: #9aa6bc;
  --ink-3: #6f7b90;

  /* accents */
  --accent: #7c7cf8;
  --accent-hover: #9a99ff;
  --accent-ink: #0a0b12;
  --accent-soft: rgba(124, 124, 248, .13);
  --accent-line: rgba(124, 124, 248, .32);

  --ok: #63e2a4;
  --ok-soft: rgba(46, 207, 125, .12);
  --ok-line: rgba(46, 207, 125, .3);

  --warn: #f7c073;
  --warn-soft: rgba(242, 169, 59, .12);
  --warn-line: rgba(242, 169, 59, .3);

  --danger: #ff8a95;
  --danger-soft: rgba(255, 95, 109, .12);
  --danger-line: rgba(255, 95, 109, .3);

  --violet: #c3a8ff;
  --violet-soft: rgba(168, 126, 255, .12);
  --violet-line: rgba(168, 126, 255, .28);

  /* formes */
  --r-xs: 5px;
  --r-sm: 8px;
  --r: 10px;
  --r-lg: 14px;

  /* ombres */
  --sh-1: 0 1px 2px rgba(0, 0, 0, .45);
  --sh-2: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 40px -26px rgba(0, 0, 0, .95);
  --sh-btn: 0 1px 2px rgba(0, 0, 0, .45);
  --ring: 0 0 0 3px rgba(124, 124, 248, .22);

  --pad: 20px;
  --maxw: 1400px;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--line-strong) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 480px at 50% -300px, rgba(124, 124, 248, .16), transparent 72%),
    radial-gradient(900px 380px at 100% 0%, rgba(46, 207, 125, .05), transparent 65%),
    var(--canvas);
  background-color: var(--canvas);
  color: var(--ink);
  font: 400 15px/1.55 "Inter", ui-sans-serif, system-ui, -apple-system,
        "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: rgba(124, 124, 248, .32); color: #fff; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .14s ease;
}
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

p { margin: 0 0 16px; }
.card p:last-child { margin-bottom: 0; }
.muted { color: var(--ink-2); }

h1,
h2 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -.022em;
  line-height: 1.25;
}

h1 {
  font-size: 1.5rem;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}

h2 {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-3);
  margin: 26px 0 12px;
}

/* --------------------------------------------------------------------------
   3. Entête
   -------------------------------------------------------------------------- */

.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.bar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--pad);
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -.02em;
}
.brand:hover { color: var(--ink); opacity: .78; }

nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}

nav a,
button.link {
  padding: 7px 11px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: .89rem;
  line-height: 1.2;
  transition: background .14s ease, color .14s ease;
}
nav a:hover { background: var(--surface-3); color: var(--ink); }

button.link {
  background: none;
  border: 0;
  font-family: inherit;
  cursor: pointer;
}
button.link:hover { background: var(--danger-soft); color: var(--danger); }

form.inline { display: inline; margin: 0; }

/* --------------------------------------------------------------------------
   4. Structure
   -------------------------------------------------------------------------- */

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px var(--pad) 56px;
}

.card {
  margin: 0 auto;
  padding: 26px 28px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}

.card.narrow {
  max-width: 460px;
  margin-top: clamp(32px, 9vh, 96px);
}

.row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 18px;
}

/* --------------------------------------------------------------------------
   5. Formulaires
   -------------------------------------------------------------------------- */

label {
  display: block;
  margin: 0 0 16px;
  color: var(--ink-2);
  font-size: .8rem;
  font-weight: 550;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: .925rem;
  line-height: 1.45;
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
input:hover,
select:hover,
textarea:hover { border-color: var(--line-strong); }
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
input::placeholder,
textarea::placeholder { color: var(--ink-3); }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

textarea {
  min-height: 96px;
  line-height: 1.6;
  resize: vertical;
}

label.check {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 24px;
  color: var(--ink);
  font-size: .9rem;
}
label.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   6. Boutons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--sh-btn);
  font: inherit;
  font-size: .895rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, transform .1s ease,
              box-shadow .14s ease, color .14s ease;
}
.btn:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn:active { transform: translateY(1px); }

.btn.ghost {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--sh-1);
}
.btn.ghost:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn.danger-btn {
  background: #e03a4a;
  border-color: transparent;
  color: #fff;
}
.btn.danger-btn:hover { background: #ef4a5a; color: #fff; }

/* --------------------------------------------------------------------------
   7. Alertes
   -------------------------------------------------------------------------- */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 16px;
  border: 1px solid;
  border-radius: var(--r-sm);
  font-size: .89rem;
  line-height: 1.5;
  box-shadow: var(--sh-1);
}
.alert::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 50%;
  background: currentColor;
}
.alert.ok {
  background: var(--ok-soft);
  border-color: var(--ok-line);
  color: var(--ok);
}
.alert.err {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   8. Indicateurs
   -------------------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  padding: 15px 17px 14px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
  --tone: var(--line-strong);
}

.stat b {
  display: block;
  font-size: 1.7rem;
  font-weight: 650;
  letter-spacing: -.035em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat span {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  color: var(--ink-3);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .085em;
}
.stat span::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tone);
  box-shadow: 0 0 10px -1px var(--tone);
}

.stat.used { --tone: var(--danger); }
.stat.free { --tone: var(--ok); }
.stat.res { --tone: var(--warn); }

/* --------------------------------------------------------------------------
   9. Filtres
   -------------------------------------------------------------------------- */

.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
}
.filters input,
.filters select { width: auto; margin: 0; }
.filters input[type="search"] { flex: 1 1 280px; min-width: 200px; }
.filters .btn { padding: 9px 15px; }

/* --------------------------------------------------------------------------
   10. Tableau
   -------------------------------------------------------------------------- */

.tablewrap {
  overflow: auto;
  max-height: calc(100vh - 300px);
  min-height: 140px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-2);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.tablewrap::-webkit-scrollbar { width: 11px; height: 11px; }
.tablewrap::-webkit-scrollbar-track { background: transparent; }
.tablewrap::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid var(--surface);
  border-radius: 99px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .89rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 10px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--ink-3);
  font-size: .69rem;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .085em;
  white-space: nowrap;
}

tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s ease; }
tbody tr:hover td { background: var(--surface-in); }

.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
  font-size: .815rem;
  letter-spacing: -.012em;
  font-variant-numeric: tabular-nums;
}

td.mono:first-child {
  color: #d8e4ff;
  font-weight: 550;
}

td.ptr {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-2);
}

td.desc {
  min-width: 170px;
  max-width: 250px;
  color: var(--ink-2);
  font-size: .855rem;
  line-height: 1.45;
  white-space: normal;
}

.empty {
  padding: 56px 20px;
  color: var(--ink-3);
  font-size: .92rem;
  text-align: center;
  white-space: normal;
}

/* --------------------------------------------------------------------------
   11. Étiquettes
   -------------------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid;
  border-radius: var(--r-xs);
  font-size: .705rem;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.5;
  white-space: nowrap;
}

.badge.v4 {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: #a8b8ff;
}
.badge.v6 {
  background: var(--violet-soft);
  border-color: var(--violet-line);
  color: var(--violet);
}
.badge.used {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger);
}
.badge.free {
  background: var(--ok-soft);
  border-color: var(--ok-line);
  color: var(--ok);
}
.badge.reserved {
  background: var(--warn-soft);
  border-color: var(--warn-line);
  color: var(--warn);
}

/* --------------------------------------------------------------------------
   12. Actions de ligne
   -------------------------------------------------------------------------- */

.actions {
  text-align: right;
  white-space: nowrap;
}
.actions a {
  display: inline-block;
  margin-left: 4px;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  color: var(--ink-2);
  font-size: .8rem;
  font-weight: 550;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.actions a:hover {
  background: var(--surface-3);
  border-color: var(--line);
  color: var(--ink);
}

.danger { color: var(--danger); }
.actions a.danger { color: var(--danger); }
.actions a.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   13. Pagination
   -------------------------------------------------------------------------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 20px;
  color: var(--ink-2);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
}
.pager span { color: var(--ink-3); }

/* --------------------------------------------------------------------------
   14. Adaptations
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .tablewrap { max-height: none; }
}

@media (max-width: 720px) {
  :root { --pad: 14px; }
  .bar { min-height: 56px; }
  .container { padding-top: 18px; padding-bottom: 36px; }
  .card { padding: 20px 18px; border-radius: var(--r); }
  .card.narrow { margin-top: 4vh; }
  h1 { font-size: 1.28rem; padding-bottom: 13px; margin-bottom: 16px; }
  h2 { margin-top: 22px; }
  .stat b { font-size: 1.45rem; }
  .filters { padding: 10px; }
  .filters input[type="search"] { flex: 1 1 100%; }
  .filters .btn { flex: 1 1 auto; }
  nav a { padding: 6px 9px; }
}

@media (max-width: 640px) {
  th:nth-child(9),
  td.desc { display: none; }
}

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

/* --------------------------------------------------------------------------
   15. Impression
   -------------------------------------------------------------------------- */

@media print {
  :root {
    color-scheme: light;
    --canvas: #fff;
    --surface: #fff;
    --surface-2: #f4f5f7;
    --surface-in: #fff;
    --ink: #111;
    --ink-2: #333;
    --ink-3: #555;
    --line: #ccc;
    --line-soft: #e2e4e8;
    --line-strong: #bbb;
  }
  body { background: #fff; color: #111; font-size: 11px; }
  .top,
  .filters,
  .actions,
  .pager,
  .stats,
  .alert,
  form { display: none !important; }
  .container { max-width: none; padding: 0; margin: 0; }
  .card {
    background: #fff;
    border-color: #ccc;
    box-shadow: none;
    padding: 0;
  }
  h1 { border-color: #ddd; color: #111; }
  .tablewrap {
    overflow: visible;
    max-height: none;
    border: 1px solid #ccc;
    box-shadow: none;
  }
  table { font-size: 10px; }
  thead th { position: static; background: #f2f4f7; color: #333; border-bottom: 1px solid #bbb; }
  tbody td { color: #111; white-space: normal; }
  .badge {
    background: none !important;
    border-color: #bbb;
    color: #111 !important;
    border-radius: 3px;
  }
  tr { break-inside: avoid; }
}
