@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root{
  --bg: #050b18;
  --text: #e8edf7;
  --muted: #9fb1c7;
  --surface: rgba(255,255,255,0.04);
  --surface-strong: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.12);
  --primary: #0ea5e9;
  --primary-strong: #22d3ee;
  --success: #22c55e;
  --danger: #f87171;
  --soft: #cbd5f5;
  --badge-ok: #10b981;
  --badge-warn: #f59e0b;
  --badge-err: #ef4444;
  --card-shadow: 0 24px 70px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; padding:26px; background:var(--bg); color:var(--text);
  font: 15px/1.6 "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  position:relative;
}

body::before{
  content:"";
  position:fixed; inset:0;
  background:
    radial-gradient(900px 900px at 10% 20%, rgba(14,165,233,0.16), transparent),
    radial-gradient(800px 800px at 80% 0%, rgba(16,185,129,0.12), transparent),
    linear-gradient(145deg, rgba(255,255,255,0.03), rgba(255,255,255,0.00) 45%);
  pointer-events:none;
  z-index:-2;
}

/* ====== Layout ====== */
.topbar{ display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:18px; }
.topbar h1{ margin:4px 0 6px; font-size:28px; }
.eyebrow{ letter-spacing:0.08em; text-transform:uppercase; font-size:11px; color:var(--muted); margin:0 0 4px; }
.subtitle{ margin:0; color:var(--muted); font-size:14px; }
.top-actions{ display:flex; align-items:center; gap:8px; }
.status-chip{
  border:1px solid var(--border);
  border-radius:12px;
  padding:8px 12px;
  background:rgba(255,255,255,0.04);
  min-width:126px;
  text-align:right;
}

.dashboard{
  display:grid;
  gap:16px;
  grid-template-columns: 1.25fr 1fr;
  grid-template-areas:
    "ap capture"
    "logs capture"
    "diag suricata"
    "manual manual";
  align-items:start;
}

.card{ background:var(--surface); border:1px solid var(--border); border-radius:16px;
  box-shadow: var(--card-shadow); padding:16px; backdrop-filter: blur(10px);
}
.card.ap{ grid-area:ap; }
.card.capture{ grid-area:capture; }
.card.logs{ grid-area:logs; }
.card.diag{ grid-area:diag; }
.card.suricata{ grid-area:suricata; }
.card.manual{ grid-area:manual; }

@media (max-width:1080px){
  body{ padding:18px; }
  .dashboard{
    grid-template-columns: 1fr;
    grid-template-areas:
      "ap"
      "capture"
      "logs"
      "diag"
      "suricata"
      "manual";
  }
}

.card-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:6px; }
.card h2{ margin:0 0 4px; font-size:20px; }
.status-chip .badge{ font-weight:600; }

.form-grid{
  display:grid;
  gap:12px 14px;
  margin:12px 0;
}
.form-grid.two{ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid.three{ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

label{ color:var(--muted); font-size:13px; display:flex; flex-direction:column; gap:6px; }
label.checkbox{ flex-direction:row; align-items:center; gap:10px; }

input, select, button{
  border:1px solid var(--border); background:var(--surface-strong); color:var(--text);
  border-radius:12px; padding:10px 12px; outline:none;
  transition: border-color .15s ease, box-shadow .15s ease, transform .08s ease;
}
input:focus, select:focus{ border-color:var(--primary); box-shadow:0 0 0 4px rgba(14,165,233,0.15); }

.cta-row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.chip-row{ display:flex; gap:10px; flex-wrap:wrap; margin:10px 0 6px; }
.inline-form{ display:flex; flex-wrap:wrap; gap:10px; align-items:center; justify-content:space-between; }

/* ====== Buttons ====== */
button{ cursor:pointer; border:1px solid transparent; font-weight:600; letter-spacing:0.01em; }
button.primary{ background:linear-gradient(120deg, var(--primary), var(--primary-strong)); color:#04101d; }
button.success{ background:linear-gradient(120deg, #22c55e, #86efac); color:#02240f; }
button.danger{ background:linear-gradient(120deg, #f87171, #fbbf24); color:#190404; }
button.soft{ background:transparent; color:var(--soft); border:1px dashed var(--border); }
button:hover{ transform: translateY(-1px); filter:brightness(1.05); }
button:active{ transform: translateY(0); }

.mode-switch{
  display:flex;
  gap:8px;
  background:rgba(255,255,255,0.05);
  padding:6px;
  border-radius:12px;
  border:1px solid var(--border);
}
.mode-toggle{
  min-width:120px;
  background:rgba(255,255,255,0.04);
  border:1px solid var(--border);
}
.mode-toggle.active{
  background:linear-gradient(120deg, var(--primary), var(--primary-strong));
  color:#04101d;
  border-color: transparent;
  box-shadow:0 8px 22px rgba(14,165,233,0.35);
}
.visually-hidden{ position:absolute; left:-9999px; width:1px; height:1px; overflow:hidden; }
.mode-wg-only{ display:none; }
.mode-wireguard .mode-wg-only{ display:grid; }
.mode-wireguard .ap-only{ display:none; }
.mode-ap .mode-wg-only{ display:none; }
.mode-ap .ap-only{ display:block; }

a{ color:var(--primary-strong); text-decoration:none; }
a:hover{ text-decoration:underline; }
.ghost{
  padding:9px 12px; border:1px solid var(--border); border-radius:12px; color:var(--text);
  text-decoration:none; background:rgba(255,255,255,0.04);
}

/* ====== Banner ====== */
.banner{
  position:sticky; top:0; z-index:10; margin:0 0 14px; padding:12px 14px;
  border-radius:12px; border:1px solid var(--border); display:none;
  background:rgba(255,255,255,0.04); box-shadow:0 8px 30px rgba(0,0,0,0.25);
}
.banner.ok{ border-color:rgba(16,185,129,0.45); background:rgba(16,185,129,0.12); }
.banner.err{ border-color:rgba(239,68,68,0.5); background:rgba(239,68,68,0.10); }

/* ====== Badges ====== */
.badge{display:inline-block;padding:4px 10px;border-radius:14px;font-size:12px;border:1px solid var(--border);}
.badge.ok{background:rgba(16,185,129,0.12);color:#befae2;border-color:rgba(16,185,129,0.45);}
.badge.err{background:rgba(239,68,68,0.12);color:#ffd1d1;border-color:rgba(239,68,68,0.5);}
.badge.warn{background:rgba(245,158,11,0.14);color:#ffe8b3;border-color:rgba(245,158,11,0.45);}

/* ====== Tooltip ====== */
[data-tip]{ position:relative; }
[data-tip]:hover::after,
[data-tip]:focus-visible::after{
  content: attr(data-tip);
  position:absolute; left:0; bottom:calc(100% + 8px);
  background:#0b1222; color:#e8edf7; padding:10px 12px; border-radius:10px;
  border:1px solid var(--border); box-shadow:0 12px 30px rgba(0,0,0,0.35);
  width:max-content; max-width:280px; z-index:12; font-size:12px; line-height:1.35;
}
[data-tip]:hover::before,
[data-tip]:focus-visible::before{
  content:""; position:absolute; left:14px; bottom:calc(100% + 2px);
  border:8px solid transparent; border-top-color:var(--border); z-index:11;
}

/* ====== Log/mono ====== */
pre.logbox{
  background:#0b1222; color:#e5e7eb; border-radius:12px; padding:12px; min-height:110px;
  overflow:auto; border:1px solid #1f2a44;
  font: 12.5px/1.4 ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
}

.data-list{
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
  min-height:40px;
  max-height:220px;
  overflow:auto;
  background: rgba(255,255,255,0.02);
}
.data-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 0;
  border-bottom:1px solid var(--border);
  font-size:13px;
}
.data-row:last-child{border-bottom:0;}
.data-row input{margin:0;}
.data-row .path{flex:1; font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;}

/* ====== Table ====== */
table{ border-collapse:collapse; width:100%; margin:8px 0; }
th,td{ border:1px solid var(--border); padding:8px; font-size:14px; vertical-align:top; }
th{ background: rgba(255,255,255,0.04); text-align:left; }
tbody tr:nth-child(odd){ background: rgba(255,255,255,0.02); }

/* Canvas traffico colora onda */
#wave{
  display:block;
  width:100%;
  height:72px;               /* la HiDPI system lo ridimensiona correttamente */
  background:#02070f;        /* scuro per massimizzare il contrasto */
  border:1px solid #1f2937;  /* grigio scuro */
  border-radius:10px;
  margin:6px 0 8px;
}

/* ====== QR area ====== */
.qr-wrap{ display:flex; gap:16px; align-items:center; }
.qr-wrap img{ width:164px; height:164px; object-fit:contain; border-radius:12px; border:1px solid var(--border); background:rgba(255,255,255,0.05); }
.qr-meta .muted{ color:var(--muted); }

/* ====== Misc ====== */
code{ background: rgba(255,255,255,0.08); padding:2px 6px; border-radius:8px; }
.muted{ color:var(--muted); }

.stacked{ display:flex; flex-direction:column; gap:6px; }
