:root {
  --bg: #070707;
  --card: rgba(14, 14, 15, .78);
  --card2: rgba(22, 22, 24, .9);
  --line: rgba(255, 255, 255, .08);
  --line2: rgba(255, 255, 255, .16);
  --fg: #ededed;
  --mut: #8d8d8d;
  --dim: #555;
  --acc: #a594ff;
  --ok: #6ee7b7;
  --warn: #fbbf77;
  --bad: #f88a8a;
  --sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'Cascadia Code', monospace;
  --pad: clamp(1rem, 3vw, 2.25rem);
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { background: var(--bg); }
body {
  background: var(--bg); color: var(--fg); font-family: var(--sans); line-height: 1.5;
  -webkit-font-smoothing: antialiased; user-select: none; overflow: hidden;
}
::selection { background: var(--acc); color: #000; }
a { color: inherit; text-decoration: none; }
img, a { -webkit-user-drag: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }

/* Sfondo: griglia di punti appena visibile, come nel portfolio */
.backdrop {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 100%);
}

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  padding: .72rem 1.25rem; border-radius: 99px; font-size: .88rem; font-weight: 500;
  background: var(--fg); color: var(--bg); border: 1px solid var(--fg);
  transition: background .3s, color .3s, border-color .3s, opacity .3s; white-space: nowrap;
}
.btn:hover { background: transparent; color: var(--fg); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--line2); }
.btn-ghost:hover { border-color: var(--fg); }
.btn-sm { padding: .5rem .95rem; font-size: .82rem; }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.danger:hover, .btn.confirm { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; transition: background .4s, box-shadow .4s; }
.dot.running { background: var(--ok); box-shadow: 0 0 10px rgba(110, 231, 183, .55); }
.dot.starting, .dot.stopping { background: var(--warn); }
.pulse { animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* ---------- Avvio / risveglio ---------- */
.boot {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 50;
  font-family: var(--mono); font-size: .8rem; color: var(--mut);
  transition: opacity .5s var(--ease);
}
.boot .row { display: flex; align-items: center; gap: .6rem; }
.boot.out { opacity: 0; pointer-events: none; }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: center;
  padding: var(--pad); max-width: 1180px; margin: 0 auto;
}
.login h1 {
  font-size: clamp(4rem, 13vw, 9.5rem); font-weight: 600; letter-spacing: -.055em; line-height: .9;
  margin: 0 0 1.4rem;
}
.login .lead { color: var(--mut); font-size: clamp(1rem, 1.6vw, 1.2rem); max-width: 34ch; margin: 0 0 2.4rem; }
.login .actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.login .err { color: var(--bad); font-size: .88rem; margin: 0 0 1.4rem; min-height: 1.3em; }
.tgwait {
  margin-top: 1.6rem; display: flex; align-items: center; flex-wrap: wrap; gap: 1rem;
  padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 18px; background: var(--card);
  max-width: 520px;
}
.tgwait .txt { display: flex; align-items: center; gap: .6rem; color: var(--mut); font-size: .88rem; flex: 1; min-width: 180px; }
.login .foot { position: absolute; bottom: var(--pad); left: var(--pad); font-family: var(--mono); font-size: .72rem; color: var(--dim); }
@media (max-height: 640px) {
  .login { position: static; min-height: 100%; padding-top: 2rem; padding-bottom: 2rem; }
  .login .foot { position: static; margin-top: 2rem; }
  .login .mark { width: 48px; height: 48px; margin-bottom: 1.4rem; }
  body { overflow: auto; }
}

/* ---------- App ---------- */
.app { height: 100%; display: flex; flex-direction: column; }

.hdr {
  position: relative; z-index: 20; display: flex; align-items: center; gap: 1.2rem;
  padding: 1.1rem var(--pad); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; font-size: 1.05rem; letter-spacing: -.02em; display: flex; align-items: center; gap: .55rem; }
.brand img { width: 22px; height: 22px; display: block; }
.login .mark { width: 64px; height: 64px; margin-bottom: 2.2rem; animation-delay: 0s; }
.hdr .spacer { flex: 1; }
.hdr .nav { display: flex; align-items: center; gap: 1.6rem; font-size: .86rem; color: var(--mut); }
.hdr .nav a, .hdr .nav button { position: relative; transition: color .3s; padding: .2rem 0; }
.hdr .nav a::after, .hdr .nav button::after {
  content: ""; position: absolute; left: 0; bottom: -2px; width: 100%; height: 1px; background: var(--fg);
  transform: scaleX(0); transform-origin: right; transition: transform .5s var(--ease);
}
.hdr .nav a:hover, .hdr .nav button:hover { color: var(--fg); }
.hdr .nav a:hover::after, .hdr .nav button:hover::after { transform: scaleX(1); transform-origin: left; }
.hdr .who { font-family: var(--mono); font-size: .76rem; color: var(--dim); }
.online b { color: var(--fg); font-weight: 600; }

.body { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px 1fr; grid-template-rows: minmax(0, 1fr); }

/* Lista server */
.side { border-right: 1px solid var(--line); overflow-y: auto; padding: 1.2rem 1rem 2rem; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.group { margin-bottom: 1.6rem; }
.group h3 {
  margin: 0 .6rem .55rem; font: 500 .7rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim);
  display: flex; justify-content: space-between;
}
.srv {
  width: 100%; text-align: left; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .15rem .7rem;
  padding: .7rem .75rem; border-radius: 14px; border: 1px solid transparent;
  transition: background .3s, border-color .3s;
}
.srv:hover { background: rgba(255, 255, 255, .025); }
.srv.active { background: var(--card); border-color: var(--line2); }
.srv .name { font-size: .92rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srv .pl { font-family: var(--mono); font-size: .72rem; color: var(--mut); }
.srv .meta { grid-column: 2 / 4; font-family: var(--mono); font-size: .7rem; color: var(--dim); display: flex; gap: .8rem; }
.srv .bar { grid-column: 2 / 4; height: 2px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: .25rem; }
.srv .bar span { display: block; height: 100%; background: var(--fg); opacity: .55; transition: width .8s var(--ease); }

/* Pannello server */
.main { min-width: 0; display: flex; flex-direction: column; padding: 1.6rem var(--pad) 1.4rem; gap: 1.2rem; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 1.5rem; }
.head .tt { flex: 1; min-width: 240px; }
.head .grp { font: 500 .72rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin-bottom: .6rem; display: flex; align-items: center; gap: .6rem; }
.head h2 { margin: 0; font-size: clamp(2rem, 4.2vw, 3.4rem); font-weight: 600; letter-spacing: -.045em; line-height: 1; }
.head .acts { display: flex; flex-wrap: wrap; gap: .5rem; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
.stat { border: 1px solid var(--line); border-radius: 14px; padding: .75rem .9rem; background: var(--card); }
.stat .k { font: 500 .68rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.stat .v { margin-top: .45rem; font-family: var(--mono); font-size: .92rem; }
.stat .v small { color: var(--dim); font-size: .75rem; }

.console {
  flex: 1; min-height: 0; overflow: auto; margin: 0; padding: 1rem 1.15rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  font: 12.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word; color: #cfcfcf;
  user-select: text; scrollbar-width: thin; scrollbar-color: var(--line2) transparent;
}
.console .muted { color: var(--dim); }

.input { display: flex; gap: .6rem; }
.field {
  flex: 1; display: flex; align-items: center; gap: .7rem; padding: 0 1.1rem;
  border: 1px solid var(--line2); border-radius: 99px; background: var(--card); transition: border-color .3s;
}
.field:focus-within { border-color: var(--fg); }
.field span { font-family: var(--mono); color: var(--acc); }
.field input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; padding: .78rem 0; font: .86rem var(--mono); caret-color: var(--acc); user-select: text; }
.field input::placeholder { color: var(--dim); }

.fade { animation: fade .6s var(--ease) both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.toast {
  position: fixed; right: var(--pad); bottom: var(--pad); z-index: 60; max-width: 460px;
  padding: .8rem 1rem; border-radius: 14px; border: 1px solid var(--line2); background: var(--card2);
  backdrop-filter: blur(12px); font-size: .86rem; opacity: 0; transform: translateY(10px);
  transition: opacity .4s var(--ease), transform .4s var(--ease); pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-color: rgba(248, 138, 138, .4); }

/* Cursore: pallino bianco come nel portfolio */
.cursor-dot {
  position: fixed; top: 0; left: 0; z-index: 10000; pointer-events: none; border-radius: 50%;
  width: 12px; height: 12px; margin: -6px 0 0 -6px; background: #fff; mix-blend-mode: difference; opacity: 0;
  transition: opacity .25s, width .35s var(--ease), height .35s var(--ease), margin .35s var(--ease);
}
.cursor-on .cursor-dot { opacity: 1; }
.cursor-dot.hover { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
@media (pointer: fine) { .cursor-on, .cursor-on * { cursor: none !important; } }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  body { overflow: auto; }
  .body { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: .8rem; display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; }
  .group { margin: 0; display: contents; }
  .group h3 { display: none; }
  .srv { width: auto; min-width: 170px; border-color: var(--line); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app { height: auto; min-height: 100%; }
  .console { flex: none; height: 60vh; }
  .head h2 { font-size: 2.2rem; }
  .hdr .nav .hide-m { display: none; }
}
