:root {
  --bg: #161616;
  --surface: #1e1e1e;
  --topbar: #1d1d1d;
  --raised: #292929;
  --line: #343434;
  --line-strong: #6e6e6e;
  --muted: #a8a8a8;
  --text: #f3f3f3;
  --primary: #f3f3f3;
  --primary-hover: #d2d2d2;
  --on-primary: #161616;
  --danger: #f06b73;
  --ok: #56d68b;
  --warn: #e8b955;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f3f3f3;
  --surface: #ffffff;
  --topbar: #ffffff;
  --raised: #ebebeb;
  --line: #d9d9d9;
  --line-strong: #868686;
  --muted: #5c5c5c;
  --text: #181818;
  --primary: #1f1f1f;
  --primary-hover: #404040;
  --on-primary: #ffffff;
  --danger: #bd2639;
  --ok: #1f8f4e;
  --warn: #a37613;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button { font: inherit; }
.mono { font-family: 'Geist Mono', ui-monospace, 'SF Mono', Consolas, monospace; }
.tiny { font-size: 12px; color: var(--muted); }
.hidden { display: none !important; }

/* ---------- auth ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 30% 10%, rgba(255,255,255,.05), transparent 55%), var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--line-strong);
  display: grid; place-items: center;
  font-weight: 600; font-size: 15px;
}
.brand-name { font-weight: 600; letter-spacing: .14em; font-size: 13px; line-height: 1.2; }
.brand-sub { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.auth .brand { margin-bottom: 22px; }
.auth h1 { font-size: 21px; font-weight: 600; margin-bottom: 6px; }
.auth p.lead { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }

/* ---------- controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  font-size: 11.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
input[type='text'], input[type='password'], input[type='search'], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 13px;
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--muted); opacity: .75; }
input:focus, select:focus, textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(255,255,255,.06);
}
input.mono { letter-spacing: .04em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--raised); color: var(--text);
  padding: 10px 16px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: var(--line-strong); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: rgba(240,107,115,.35); background: transparent; }
.btn-danger:hover { border-color: var(--danger); background: rgba(240,107,115,.08); }
.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--line); }

.alert {
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px;
  border: 1px solid rgba(240,107,115,.4); background: rgba(240,107,115,.08); color: var(--danger);
}
.hint { color: var(--muted); font-size: 12.5px; margin-top: 12px; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 11px clamp(16px, 3vw, 28px);
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; white-space: nowrap; }
.topbar .who strong { color: var(--text); font-weight: 600; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  align-items: start;
}
@media (max-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 20px clamp(14px, 2vw, 22px);
  display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 57px;
}
@media (max-width: 880px) {
  .sidebar { position: static; border-right: 0; border-bottom: 1px solid var(--line); }
}
.sidebar-head { display: flex; align-items: baseline; justify-content: space-between; }
.sidebar h2 { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.vps-list { display: flex; flex-direction: column; gap: 6px; }
.vps-item {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent;
  color: var(--text); border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.vps-item:hover { background: var(--surface); }
.vps-item.active { background: var(--surface); border-color: var(--line); }
.vps-item .name { font-weight: 600; font-size: 14px; display: block; }
.vps-item .meta { color: var(--muted); font-size: 12px; display: block; }

.content {
  min-width: 0;
  padding: clamp(16px, 3vw, 30px);
  display: flex; flex-direction: column; gap: 18px;
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.stat .value { font-size: 22px; font-weight: 600; line-height: 1.2; }
.stat .label { color: var(--muted); font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; }

.card {
  min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; display: flex; flex-direction: column; gap: 14px;
}
.card-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-header .spacer { flex: 1; }
.card p.sub { color: var(--muted); font-size: 13px; }

/* ---------- forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 12px;
  align-items: end;
}
.form-grid .field-action { justify-content: flex-end; }
.form-grid .field-action .btn { width: 100%; }
.form-grid.compact { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)) auto; }

.search-input {
  width: 220px;
  max-width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  outline: none;
}
.search-input:focus { border-color: var(--line-strong); }

/* ---------- table ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.025); }
td.actions { text-align: right; white-space: nowrap; }
tr.primary-row td { background: rgba(86,214,139,.05); }
tr.primary-row td:first-child { box-shadow: inset 2px 0 0 var(--ok); }
td.actions .btn + .btn { margin-left: 6px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 2px 10px; font-size: 12px; border: 1px solid var(--line);
  white-space: nowrap;
}
.tag-ok { color: var(--ok); border-color: rgba(86,214,139,.4); background: rgba(86,214,139,.08); }
.tag-off { color: var(--muted); }
.tag-danger { color: var(--danger); border-color: rgba(240,107,115,.4); background: rgba(240,107,115,.08); }
.tag-warn { color: var(--warn); border-color: rgba(232,185,85,.4); background: rgba(232,185,85,.08); }
.tag-owner { color: var(--text); border-color: var(--line); background: var(--raised); }

/* valeurs sensibles : masquees mais copiables */
.secret {
  cursor: pointer;
  border-bottom: 1px dashed var(--line-strong);
  letter-spacing: .04em;
}
.secret:hover { color: var(--text); border-bottom-color: var(--text); }
.btn-copy {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 7px;
  margin-left: 8px;
  color: var(--muted);
  background: transparent;
}
.btn-copy:hover { color: var(--text); }
.vps-ip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.vps-ip .mono { color: var(--text); font-size: 12.5px; }

.empty { color: var(--muted); font-size: 13px; padding: 14px 2px; }

/* ---------- verdict / legend ---------- */
.legend { display: flex; gap: 8px; flex-wrap: wrap; }
.verdict { border-radius: 12px; padding: 16px; border: 1px solid var(--line); background: var(--bg); }
.verdict .headline { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; }
.verdict .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.verdict.allowed { border-color: rgba(86,214,139,.45); background: rgba(86,214,139,.07); }
.verdict.allowed .dot { background: var(--ok); }
.verdict.spoof, .verdict.denied, .verdict.disabled { border-color: rgba(240,107,115,.45); background: rgba(240,107,115,.07); }
.verdict.spoof .dot, .verdict.denied .dot, .verdict.disabled .dot { background: var(--danger); }
.verdict.unknown, .verdict.ip_not_allowed { border-color: rgba(232,185,85,.45); background: rgba(232,185,85,.07); }
.verdict.unknown .dot, .verdict.ip_not_allowed .dot { background: var(--warn); }
.verdict .reason { color: var(--muted); font-size: 13px; margin-top: 6px; }
.verdict .expected { font-size: 13px; margin-top: 8px; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; font-size: 13.5px; box-shadow: 0 12px 30px rgba(0,0,0,.35);
  opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .18s;
  pointer-events: none; max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(240,107,115,.5); color: var(--danger); }

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

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 20px; z-index: 40;
}
.modal { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.modal h3 { margin-bottom: 14px; font-size: 16px; }
.modal .field { margin-bottom: 12px; }
