:root {
  --bg:        #0a0e14;
  --bg-panel:  #0f141c;
  --bg-elev:   #151c26;
  --bg-input:  #0b1017;
  --border:    #1f2935;
  --border-hi: #2b3a4d;
  --fg:        #d7e0ea;
  --muted:     #6b7a8d;
  --accent:    #2ee6a6;   /* terminal green */
  --accent-dim:#1b9e74;
  --cyan:      #38bdf8;
  --amber:     #f5b942;
  --red:       #ff5c6c;
  --purple:    #a78bfa;
  --radius:    10px;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(46,230,166,0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(56,189,248,0.05), transparent 60%),
    var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(46,230,166,0.25); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--bg-panel), #0b0f16);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px; font-weight: 800; font-size: 18px; letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
}
.brand .logo {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: grid; place-items: center; color: #03110b; font-weight: 900; font-size: 15px;
  box-shadow: 0 0 18px rgba(46,230,166,0.4);
}
.brand b { color: var(--fg); }
.brand b span { color: var(--accent); }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav .group { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 2px 0; border-radius: 8px;
  color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent;
}
.nav a:hover { color: var(--fg); background: var(--bg-elev); text-decoration: none; }
.nav a.active {
  color: var(--accent); background: rgba(46,230,166,0.08);
  border-color: rgba(46,230,166,0.25);
}
.nav a svg { width: 17px; height: 17px; flex: none; }

.side-foot { border-top: 1px solid var(--border); padding: 12px; }
.userchip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  background: var(--bg-elev); border: 1px solid var(--border);
}
.userchip .av {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  display: grid; place-items: center; color: #07101a; font-weight: 800; font-size: 13px;
}
.userchip .meta { overflow: hidden; }
.userchip .meta .n { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userchip .meta .r { font-size: 11px; color: var(--muted); }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px; border-bottom: 1px solid var(--border);
  background: rgba(10,14,20,0.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar .crumb { font-family: var(--mono); font-size: 14px; color: var(--muted); }
.topbar .crumb .p { color: var(--accent); }
.topbar .crumb .v { color: var(--fg); }
.content { padding: 26px; max-width: 1100px; width: 100%; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view h1 { font-size: 20px; margin: 0 0 4px; }
.view .lead { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-panel));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px;
}
.card.term { padding: 0; overflow: hidden; }
.card .term-bar {
  display: flex; align-items: center; gap: 7px; padding: 10px 14px;
  background: var(--bg-elev); border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.card .term-bar i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.card .term-bar .r1 { background: #ff5f57; } .card .term-bar .r2 { background: #febc2e; } .card .term-bar .r3 { background: #28c840; }
.card .term-bar span { margin-left: 6px; }
.card .term-body { padding: 16px 18px; }
.card h2 { margin: 0 0 4px; font-size: 15px; }
.card h3 { margin: 18px 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.card .desc { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 15px; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: #03110b; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: var(--sans); transition: filter .12s, background .12s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.full { width: 100%; }
.btn.ghost { background: var(--bg-elev); color: var(--fg); border-color: var(--border-hi); }
.btn.ghost:hover { background: var(--border); }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; filter: none; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.icon { padding: 6px 8px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
input, select {
  width: 100%; padding: 10px 12px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 8px; color: var(--fg);
  font-size: 14px; font-family: var(--sans);
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,230,166,0.12); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 130px; }
.field-inline { display: flex; gap: 10px; align-items: flex-end; }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { display: none; }
.switch .slider { position: absolute; inset: 0; background: var(--bg-input); border: 1px solid var(--border-hi); border-radius: 20px; transition: .2s; cursor: pointer; }
.switch .slider:before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: rgba(46,230,166,0.2); border-color: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(20px); background: var(--accent); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-row .info .t { font-size: 14px; font-weight: 600; }
.setting-row .info .d { font-size: 12px; color: var(--muted); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
td.actions { text-align: right; white-space: nowrap; }

/* ---------- Bits ---------- */
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; font-family: var(--mono); }
.badge.tcp { background: rgba(56,189,248,0.14); color: var(--cyan); }
.badge.udp { background: rgba(245,185,66,0.14); color: var(--amber); }
.badge.on { background: rgba(46,230,166,0.14); color: var(--accent); }
.badge.off { background: rgba(255,92,108,0.14); color: var(--red); }
.badge.admin { background: rgba(167,139,250,0.16); color: var(--purple); }
.badge.user { background: rgba(107,122,141,0.16); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.off { background: var(--red); }

.codebox {
  background: #060a0f; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font-family: var(--mono); font-size: 12.5px;
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
}
.codebox .txt { flex: 1; word-break: break-all; color: var(--accent); }
.codebox .txt .prompt { color: var(--muted); user-select: none; margin-right: 6px; }

.empty { color: var(--muted); font-size: 13px; padding: 18px; text-align: center; border: 1px dashed var(--border); border-radius: 8px; }
.err { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 16px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* stat grid */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 6px; }
.stat { background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat .n { font-size: 28px; font-weight: 800; font-family: var(--mono); }
.stat .n.accent { color: var(--accent); }
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-top: 2px; }

/* slot block */
.slot { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 14px; background: var(--bg-input); }
.slot .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.slot .head .name { font-weight: 700; font-size: 14px; }
.progress { height: 5px; background: var(--bg); border-radius: 4px; overflow: hidden; margin: 8px 0 12px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--cyan)); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  background: var(--bg-elev); border: 1px solid var(--border-hi); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 12px 16px; min-width: 240px; max-width: 360px; font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5); animation: slidein .2s ease;
}
.toast.err { border-left-color: var(--red); }
.toast.info { border-left-color: var(--cyan); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(3,6,10,0.7); backdrop-filter: blur(3px); display: none; place-items: center; z-index: 90; }
.modal-back.open { display: grid; }
.modal { background: var(--bg-panel); border: 1px solid var(--border-hi); border-radius: 12px; width: 92%; max-width: 440px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); animation: fade .15s ease; }
.modal h2 { margin: 0 0 16px; font-size: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .term-bar { border-radius: 12px 12px 0 0; }
.auth-card .inner { border: 1px solid var(--border); border-top: none; border-radius: 0 0 12px 12px; background: var(--bg-panel); padding: 26px; }
.auth-card .bigbrand { text-align: center; font-size: 25px; font-weight: 800; margin-bottom: 4px; }
.auth-card .bigbrand span { color: var(--accent); }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.auth-card .alt { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; width: 248px; }
  .sidebar.open { left: 0; }
  .content { padding: 18px; }
  .menu-btn { display: inline-flex !important; }
}
.menu-btn { display: none; }
