:root {
  --navy: #0d1424;
  --navy-soft: #131c30;
  --bg: #f4f5f8;
  --card: #ffffff;
  --border: #e8eaef;
  --text: #1f2433;
  --muted: #8a90a2;
  --muted-2: #6b7280;
  --indigo: #4f46e5;
  --indigo-dark: #4338ca;
  --indigo-soft: #eef0fe;
  --purple: #7c3aed;
  --green: #16a34a;
  --green-soft: #e7f6ec;
  --amber: #d97706;
  --amber-soft: #fdf6e3;
  --red: #dc2626;
  --red-soft: #fdecec;
  --blue-soft: #e7eefe;
  --blue-text: #3258d6;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Constrain inline SVGs so icons without explicit dimensions never blow up. */
.panel-head svg { width: 24px; height: 24px; flex-shrink: 0; }
.stat .icon svg { width: 24px; height: 24px; }
.cmd-label svg, .mode-label svg { width: 16px; height: 16px; flex-shrink: 0; }
.target-row svg, .step-btn svg, .back-link svg, .detail-row svg { width: 18px; height: 18px; flex-shrink: 0; }
.drawer-nav a svg { width: 20px; height: 20px; flex-shrink: 0; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; }
.brand .logo { color: #6366f1; display: flex; }
.hamburger {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 50px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.hamburger:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- Layout ---------- */
.container { max-width: 1240px; margin: 0 auto; padding: 28px 28px 80px; }

/* ---------- Stat cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 36px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.stat .label { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; line-height: 1.4; }
.stat .value { font-size: 34px; font-weight: 800; margin-top: 14px; }
.stat .value.green { color: var(--green); }
.stat .value.amber { color: var(--amber); }
.stat .value.purple { color: var(--purple); }
.stat .icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon.indigo { background: var(--indigo-soft); color: var(--indigo); }
.icon.green { background: var(--green-soft); color: var(--green); }
.icon.amber { background: var(--amber-soft); color: var(--amber); }
.icon.purple { background: #f3e9ff; color: var(--purple); }

/* ---------- Section header ---------- */
.section-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.section-head h1 { font-size: 30px; font-weight: 800; margin: 0 0 6px; }
.section-head p { margin: 0; color: var(--muted-2); font-size: 15px; }
.head-actions { display: flex; gap: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  border-radius: 12px; padding: 13px 20px;
  font-size: 15px; font-weight: 600; border: 1px solid transparent;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-dark); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f7f8fa; }
.btn-danger-ghost { background: var(--red-soft); color: var(--red); width: 100%; justify-content: center; padding: 16px; font-weight: 700; font-size: 16px; border: 1px solid #f7d4d4; }
.btn-danger-ghost:hover { background: #fbdcdc; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 9px 14px; font-size: 13px; border-radius: 10px; }

/* ---------- Table card ---------- */
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 14px; font-weight: 700; color: var(--muted-2); padding: 22px 24px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 20px 24px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 15px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

.client-cell { display: flex; align-items: center; gap: 14px; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--indigo-soft); color: var(--indigo); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; flex-shrink: 0; }
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.client-name { font-weight: 700; }
.client-email { color: var(--muted); font-size: 14px; margin-top: 2px; word-break: break-all; }

.targets { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.target-row { display: flex; align-items: center; gap: 8px; }
.target-row .ico-pve { color: var(--amber); }
.target-row .ico-tp { color: var(--purple); }
.target-row .k { color: var(--muted-2); }
.target-row .v { font-weight: 600; }

.manage-link { color: var(--indigo); font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.manage-link:hover { text-decoration: underline; }

.date-cell .k { color: var(--muted-2); }
.date-cell .access-yes { color: var(--green); font-weight: 700; }
.date-cell .access-no { color: var(--muted); font-style: italic; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.badge-en_creation { background: #eef0f3; color: #5b6472; }
.badge-proxmox_cree { background: var(--blue-soft); color: var(--blue-text); }
.badge-teleport_cree { background: #ede9fe; color: #6d28d9; }
.badge-mails_envoyes { background: #e0f2fe; color: #0369a1; }
.badge-onboarde { background: #e7f6ec; color: #15803d; }
.badge-revoque { background: var(--red-soft); color: var(--red); }
.badge-followup { background: var(--amber-soft); color: var(--amber); margin-left: 8px; }

/* ---------- Detail page ---------- */
.detail-grid { display: flex; flex-direction: column; gap: 24px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.panel-head { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; margin: 0 0 22px; }
.detail-top { display: flex; align-items: center; gap: 18px; margin-bottom: 8px; }
.detail-top h1 { margin: 0; font-size: 30px; }
.detail-rows { margin-top: 26px; }
.detail-row { display: flex; justify-content: space-between; padding: 14px 0; border-top: 1px solid var(--border); font-size: 16px; }
.detail-row .k { color: var(--muted-2); }
.detail-row .v { font-weight: 700; }

.subtle-label { text-transform: uppercase; letter-spacing: .06em; font-size: 13px; font-weight: 800; color: var(--muted); margin: 30px 0 14px; }
.step-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: #f6f7f9; border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; font-size: 16px; font-weight: 600; color: var(--text); text-align: left;
}
.step-btn:hover { background: #eef0f3; }
.step-btn.done { color: var(--green); }
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ---------- Code blocks ---------- */
.cmd-group { margin-top: 18px; }
.cmd-label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--muted-2); margin-bottom: 10px; }
.code {
  position: relative;
  background: var(--navy); color: #7ee787;
  font-family: var(--mono); font-size: 14px; line-height: 1.6;
  padding: 18px 56px 18px 20px; border-radius: 12px;
  white-space: pre-wrap; word-break: break-all;
}
.code .copy { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.08); border: none; color: #cbd5e1; border-radius: 8px; padding: 6px 8px; font-size: 12px; }
.code .copy:hover { background: rgba(255,255,255,.18); color: #fff; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 14px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 12px; color: var(--muted); }
input, select, textarea {
  font-family: inherit; font-size: 15px; color: var(--text);
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-soft); }
textarea { resize: vertical; min-height: 90px; }
.form-actions { display: flex; gap: 12px; margin-top: 26px; }

/* ---------- Drawer ---------- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(13, 20, 36, .55); backdrop-filter: blur(2px); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 320px; background: var(--navy); color: #fff; z-index: 70; transform: translateX(-100%); transition: transform .25s ease; display: flex; flex-direction: column; padding: 26px; }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; }
.drawer-head .brand { font-size: 22px; }
.drawer-head .sub { color: #93a0b8; font-size: 13px; margin-top: 4px; }
.drawer-close { background: none; border: none; color: #93a0b8; font-size: 26px; line-height: 1; }
.drawer-nav { margin-top: 40px; display: flex; flex-direction: column; gap: 8px; }
.drawer-nav a { display: flex; align-items: center; gap: 14px; padding: 14px 12px; border-radius: 10px; font-size: 17px; font-weight: 600; color: #e7ebf3; }
.drawer-nav a:hover, .drawer-nav a.active { background: rgba(255,255,255,.08); }
.drawer-foot { margin-top: auto; }
.drawer-foot .mode-label { display: flex; align-items: center; gap: 8px; color: #93a0b8; font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 12px; }
.mode-toggle { display: flex; gap: 8px; }
.mode-toggle button { flex: 1; padding: 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05); color: #cbd5e1; font-weight: 700; font-size: 14px; }
.mode-toggle button.active { background: var(--indigo); border-color: var(--indigo); color: #fff; }

/* ---------- Misc ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--indigo); font-weight: 600; margin-bottom: 18px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty svg { width: 48px; height: 48px; opacity: .4; margin-bottom: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--indigo); border-radius: 50%; animation: spin .7s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast { background: var(--navy); color: #fff; padding: 14px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; max-width: 340px; animation: slideIn .2s ease; }
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast.info { border-left: 4px solid var(--indigo); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }

/* ---------- Stars ---------- */
.stars { display: flex; gap: 6px; }
.stars button, .stars span { background: none; border: none; font-size: 34px; color: #d8dbe2; line-height: 1; padding: 0; }
.stars .on { color: #f5b301; }
.stars button:hover { color: #f5b301; }
.feedback-display { display: flex; align-items: center; gap: 10px; }
.feedback-display .rating { color: #f5b301; font-size: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody td { border-bottom: none; padding: 8px 20px; }
  tbody tr { border-bottom: 1px solid var(--border); padding: 14px 0; }
  td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .container { padding: 18px 16px 60px; }
}
