/* ===== HomeProxy dashboard — thème sombre soigné ===== */
:root {
  --bg-0: #0a0f1d;
  --bg-1: #0f172a;
  --surface: #151d30;
  --surface-2: #1b2540;
  --border: #28344f;
  --border-soft: #1f2940;
  --text: #e6edf7;
  --muted: #93a1ba;
  --accent: #38bdf8;
  --accent-2: #6366f1;
  --accent-hi: #0ea5e9;
  --green: #4ade80;
  --red: #f87171;
  --red-bg: #3a1d24;
  --amber: #fbbf24;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --radius: 14px;
}

* { box-sizing: border-box; }

/* L'attribut hidden doit TOUJOURS l'emporter, même sur un display: grid/flex. */
[hidden] { display: none !important; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(56, 189, 248, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(99, 102, 241, 0.10), transparent 55%),
    var(--bg-0);
  color: var(--text);
  line-height: 1.55;
}

/* ---- Header ---- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 20px; height: 20px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.55);
}
.brand-name {
  font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em;
  background: linear-gradient(90deg, #e6edf7, #9fc6ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---- Layout ---- */
main { max-width: 880px; margin: 28px auto 64px; padding: 0 18px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

/* ---- Cards ---- */
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
h2 {
  margin: 0 0 14px;
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted);
}

/* ---- Auth screen ---- */
.auth-wrap { min-height: calc(100vh - 120px); display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; margin: 0; }
.auth-card h2 { font-size: 1.3rem; text-transform: none; letter-spacing: -0.01em; color: var(--text); }

/* ---- Text helpers ---- */
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--red); min-height: 1.2em; margin: 10px 0 0; font-size: 0.9rem; }
.warn {
  color: #fcd9a3; background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25); border-radius: 10px;
  padding: 10px 12px; font-size: 0.85rem; margin: 12px 0 0;
}
.kv {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 8px 0; padding-bottom: 8px; border-bottom: 1px solid var(--border-soft);
}
.kv:last-of-type { border-bottom: none; }

/* ---- Balance hero ---- */
.balance {
  font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em; margin: 4px 0 14px;
  background: linear-gradient(90deg, var(--green), #22d3ee);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---- Badge ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 11px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; text-transform: capitalize;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.is-active { background: rgba(74, 222, 128, 0.12); color: var(--green); border-color: rgba(74, 222, 128, 0.35); }
.badge.is-inactive { background: rgba(248, 113, 113, 0.12); color: var(--red); border-color: rgba(248, 113, 113, 0.3); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---- Inputs & selects ---- */
input, select {
  font: inherit; padding: 11px 13px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-0); color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: #5b6b86; }
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}
form input { display: block; width: 100%; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.78rem; color: var(--muted); }
.field select { min-width: 130px; }

/* ---- Buttons ---- */
.btn, button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  transition: transform 0.05s, filter 0.15s, background 0.15s, border-color 0.15s;
}
.btn:active, button:active { transform: translateY(1px); }
.btn-primary, button:not(.btn) {
  color: #06121f; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-hi));
  box-shadow: 0 6px 18px -8px rgba(56, 189, 248, 0.7);
}
.btn-primary:hover, button:not(.btn):hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent; color: var(--text); border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger {
  background: transparent; color: var(--red); border: 1px solid rgba(248, 113, 113, 0.4);
}
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; border-radius: 8px; }

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

/* ---- Code blocks ---- */
code {
  font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  background: var(--bg-0); padding: 8px 11px; border-radius: 8px;
  border: 1px solid var(--border); color: #9fe7ff; word-break: break-all;
  display: inline-block;
}

/* ---- Notice box (deposit / enroll) ---- */
.notice {
  margin-top: 14px; padding: 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px dashed var(--border);
}
.notice p { margin: 0 0 8px; }
#pay-qr { margin-top: 10px; max-width: 180px; background: #fff; padding: 8px; border-radius: 10px; }

/* ---- Lists ---- */
ul { list-style: none; padding: 0; margin: 0; }

.stack-list li { padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.stack-list li:last-child { border-bottom: none; }
.stack-list strong { display: block; margin-bottom: 8px; font-size: 0.9rem; }

/* Bloc de config copiable (agent.json) */
.config-block {
  background: var(--bg-0); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; margin: 6px 0; color: #9fe7ff;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.78rem; white-space: pre-wrap; word-break: break-all;
}

/* Ligne de proxy : libellé + ligne (extensible) + bouton copier */
.proxy-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.proxy-row code { flex: 1 1 auto; min-width: 0; }
.proxy-row .btn { flex: none; }
.proxy-tag {
  flex: none; width: 88px; text-align: center;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent); background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25); border-radius: 999px; padding: 4px 0;
}
@media (max-width: 640px) {
  .proxy-row { flex-wrap: wrap; }
  .proxy-row code { flex-basis: 100%; order: 3; }
}

.node-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.node-form #node-name { flex: 1 1 200px; margin: 0; }

.node-list { margin-top: 6px; }
.node-list li {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--border-soft);
}
.node-list li:last-child { border-bottom: none; }
.node-list label {
  flex: 1 1 auto; display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 0.92rem; min-width: 0;
}
.node-list input[type="checkbox"] {
  width: 17px; height: 17px; accent-color: var(--accent); flex: none; padding: 0;
}
.node-list .btn { flex: none; }
/* Résultat de test : passe à la ligne (pleine largeur) sous le nœud. */
.node-test { flex-basis: 100%; font-size: 0.85rem; color: var(--muted); min-height: 1em; }
.node-test.ok { color: var(--green); font-weight: 600; }
.node-test.ko { color: var(--red); }

/* ---- Bouton lien (texte cliquable) ---- */
.linklike {
  background: transparent; border: none; padding: 0; font: inherit;
  color: var(--accent); cursor: pointer; text-decoration: underline;
}
.linklike:hover { filter: brightness(1.15); }

/* ---- Modal (popup) ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; padding: 20px;
  display: grid; place-items: center;
  background: rgba(5, 9, 18, 0.72); backdrop-filter: blur(4px);
}
.modal {
  width: 100%; max-width: 540px; max-height: 90vh; overflow: auto; padding: 26px;
  background: linear-gradient(180deg, var(--surface), var(--bg-1));
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h2 {
  margin: 0 0 4px; font-size: 1.2rem; text-transform: none; letter-spacing: -0.01em; color: var(--text);
}
.modal-x {
  background: transparent; border: none; color: var(--muted);
  font-size: 1.7rem; line-height: 1; cursor: pointer; padding: 0 6px;
}
.modal-x:hover { color: var(--text); }
.steps { margin: 16px 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; }
.steps li { font-size: 0.92rem; }
.steps a { color: var(--accent); }
.steps code { font-size: 0.78rem; padding: 2px 6px; }
