/* OpenVPN Manager — thème sombre, contraste vérifié, mobile-first.
   Aucune dépendance externe : tout est servi par l'application (CSP 'self'). */

:root {
  --bg: #0a1220;
  --surface: #111c31;
  --surface-2: #16233b;
  --surface-3: #1c2c48;
  --border: #24344f;
  --border-strong: #34507a;
  --text: #e8eefb;
  --text-soft: #b9c7dd;
  --muted: #8fa3c0;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, .16);
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, .14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, .14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, .14);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, .14);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Structure ─────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 268px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--surface) 0%, #0d1728 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
  color: var(--info);
  font-weight: 700; letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  border: 1px solid transparent;
  text-decoration: none;
  font-size: 14px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active {
  background: var(--accent-soft);
  border-color: var(--border-strong);
  color: #fff;
  font-weight: 600;
}
.nav-ico { width: 18px; text-align: center; color: var(--muted); }
.nav-link.active .nav-ico { color: var(--info); }
.nav-sep {
  margin: 14px 0 4px;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
}

.userbox {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 10px;
}
.userbox-ident { display: flex; flex-direction: column; }
.userbox-ident strong { font-size: 13px; }
.userbox-ident small { color: var(--muted); font-size: 12px; word-break: break-all; }
.userbox-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.userbox-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.userbox-actions form { margin: 0; }

.main { padding: 24px 28px 40px; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.topbar-scope { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Cartes, KPI ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 16px; }
.card-head .hint { color: var(--muted); font-size: 13px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kpi-hint { color: var(--muted); font-size: 12px; }
.kpi.is-danger .kpi-value { color: var(--danger); }
.kpi.is-warn .kpi-value { color: var(--warn); }
.kpi.is-ok .kpi-value { color: var(--ok); }

/* ── Tableaux ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th {
  background: var(--surface-2);
  color: var(--text-soft);
  font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.mono, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface-3); color: var(--text-soft);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); border-color: rgba(34,197,94,.45); color: #86efac; }
.badge-warn { background: var(--warn-soft); border-color: rgba(245,158,11,.45); color: #fcd34d; }
.badge-danger { background: var(--danger-soft); border-color: rgba(239,68,68,.45); color: #fca5a5; }
.badge-info { background: var(--info-soft); border-color: rgba(56,189,248,.45); color: #7dd3fc; }
.badge-accent { background: var(--accent-soft); border-color: rgba(59,130,246,.5); color: #bfdbfe; }
.badge-muted { background: var(--surface-3); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ── Boutons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-3); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer;
  text-decoration: none; line-height: 1.2;
}
.btn:hover { background: #22355a; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2f6fd8; }
.btn-danger { background: var(--danger-soft); border-color: rgba(239,68,68,.55); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,.24); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }

.inline-form { display: inline; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Formulaires ───────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.field .help { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.checkline { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-soft); }
.checkline input { width: auto; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0; }
legend { padding: 0 8px; color: var(--text-soft); font-size: 13px; font-weight: 600; }

/* ── Alertes, états vides ──────────────────────────────────────────────── */
.flashes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.alert {
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text);
  font-size: 14px;
}
.alert-success { background: var(--ok-soft); border-color: rgba(34,197,94,.45); }
.alert-error, .alert-danger { background: var(--danger-soft); border-color: rgba(239,68,68,.45); }
.alert-warning { background: var(--warn-soft); border-color: rgba(245,158,11,.45); }
.alert-info { background: var(--info-soft); border-color: rgba(56,189,248,.45); }

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ── Détails / listes de définitions ───────────────────────────────────── */
.defs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.def { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
.def dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.def dd { margin: 4px 0 0; font-size: 14px; font-weight: 600; word-break: break-word; }

pre.code {
  background: #070e19;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #cbd5e1;
  margin: 0;
}
pre.code .c { color: #64748b; }
pre.code .a { color: #86efac; }
pre.code .d { color: #fca5a5; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Connexion ─────────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 6px; font-size: 20px; }
.auth-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-foot { margin-top: 18px; color: var(--muted); font-size: 12px; text-align: center; }

/* ── Pied de page ──────────────────────────────────────────────────────── */
.footer {
  margin-top: auto; padding-top: 24px;
  display: flex; justify-content: space-between; gap: 10px;
  color: var(--muted); font-size: 12px; flex-wrap: wrap;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 12px; padding: 12px 14px;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; padding-bottom: 4px; }
  .nav-link { white-space: nowrap; }
  .nav-sep { display: none; }
  .userbox { margin: 0; width: 100%; flex-direction: row; align-items: center; justify-content: space-between; }
  .userbox-badges { display: none; }
  .main { padding: 18px 14px 32px; }
  .split { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
