:root {
  --bg: #0b1220;
  --bg-2: #111a2e;
  --surface: rgba(18, 28, 48, 0.86);
  --line: rgba(148, 175, 210, 0.16);
  --text: #e8eef8;
  --muted: #93a4bf;
  --accent: #3dd6c6;
  --accent-2: #4f8cff;
  --danger: #ff6b7a;
  --ok: #3dd6c6;
  --off: #7a879c;
  --radius: 14px;
  --font: "DM Sans", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: rgba(255,255,255,0.06);
  padding: 0.15em 0.4em;
  border-radius: 6px;
}

.home-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 12% 10%, rgba(61, 214, 198, 0.18), transparent 55%),
    radial-gradient(800px 480px at 88% 18%, rgba(79, 140, 255, 0.2), transparent 50%),
    linear-gradient(160deg, #070d18 0%, #0d1730 45%, #0a1424 100%);
  z-index: -1;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.15rem;
}
.brand-center { display: block; text-align: center; margin-bottom: 1.25rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #2bb8d4);
  color: #04131a;
}
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover { border-color: rgba(61,214,198,0.45); }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.9rem; }
.btn-block { width: 100%; }

.page-sub { min-height: 100vh; }
.sub-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  animation: rise .55s ease both;
}
.sub-header { margin-bottom: 1.5rem; }
.sub-brand {
  font-size: clamp(1.8rem, 5vw, 2.6rem) !important;
  margin-bottom: 0.35rem !important;
}
.sub-header h1 { margin: 0 0 0.35rem; font-size: 1.5rem; }
.sub-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.sub-host details.sub-link { margin-top: 0.75rem; }
.sub-host summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}
@media (max-width: 700px) {
  .sub-meta { grid-template-columns: 1fr; }
}

.home-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
}
.home-hero {
  max-width: 760px;
  padding: 12vh 2rem 4rem;
  animation: rise .7s ease both;
}
.brand-mark {
  margin: 0 0 0.75rem;
  font-size: clamp(2.4rem, 7vw, 4.4rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  background: linear-gradient(120deg, #fff 20%, var(--accent) 70%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.home-hero h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.lead { color: var(--muted); font-size: 1.05rem; max-width: 34rem; }
.cta-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.75rem; }

.page-login { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.login-wrap { width: min(100%, 400px); animation: rise .55s ease both; }
.login-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
}
.login-form h1 { margin: 0 0 0.35rem; font-size: 1.35rem; }
.muted { color: var(--muted); margin: 0 0 1rem; }
.alert {
  background: rgba(255,107,122,0.12);
  border: 1px solid rgba(255,107,122,0.35);
  color: #ffb4bc;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}
label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  font-size: 0.9rem;
  color: var(--muted);
}
input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font: inherit;
}
input:focus {
  outline: none;
  border-color: rgba(61,214,198,0.55);
  box-shadow: 0 0 0 3px rgba(61,214,198,0.12);
}

.page-admin {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background:
    radial-gradient(700px 400px at 100% 0%, rgba(79,140,255,0.12), transparent 50%),
    var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem 1.1rem;
  border-right: 1px solid var(--line);
  background: rgba(8, 14, 26, 0.75);
}
.sidebar nav { display: grid; gap: 0.35rem; }
.sidebar nav a {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 500;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(61,214,198,0.1);
  color: var(--text);
}
.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.user-chip {
  font-size: 0.9rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.admin-main { padding: 1.75rem 2rem 2.5rem; }
.admin-header h1 { margin: 0; font-size: 1.7rem; letter-spacing: -0.03em; }
.admin-header .muted { margin-top: 0.35rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin: 1.5rem 0 2rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.stat-label { display: block; color: var(--muted); font-size: 0.85rem; margin-bottom: 0.35rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.04em; }
.stat-value.accent { color: var(--accent); }

.panel-section { margin-top: 0.5rem; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-head h2 { margin: 0; font-size: 1.15rem; }

.proto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.85rem;
}
.proto-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  animation: rise .45s ease both;
}
.proto-card.is-off { opacity: 0.72; }
.proto-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.proto-top h3 { margin: 0; font-size: 1.05rem; }
.proto-card p {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 2.7em;
}
.proto-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(122,135,156,0.16);
  color: var(--muted);
  border: 1px solid var(--line);
}
.chip.on { background: rgba(61,214,198,0.15); color: var(--ok); border-color: rgba(61,214,198,0.3); }
.chip.warn { background: rgba(255,196,87,0.14); color: #ffc457; }
.chip.err { background: rgba(255,107,122,0.14); color: #ff8a96; }
.chip.off { opacity: 0.85; }

.actions-multi {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}
.row-off { opacity: 0.78; }
.proto-servers { margin-top: 0.75rem; }
.proto-servers .stat-label { margin-bottom: 0.35rem; }

.badge.warn { background: rgba(255, 196, 87, 0.16); color: #ffc457; }
.badge.err { background: rgba(255,107,122,0.15); color: #ff8a96; }

.alert.ok {
  background: rgba(61,214,198,0.12);
  border: 1px solid rgba(61,214,198,0.35);
  color: #9af0e6;
}

.row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.stats-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 760px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
  margin-bottom: 0.85rem;
}
textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font: inherit;
}
textarea { resize: vertical; font-family: var(--mono); font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: -0.35rem 0 1rem; }
.mode-pick {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin: 0 0 1.25rem;
}
.mode-pick legend { padding: 0 0.35rem; color: var(--muted); }
.radio {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin: 0.55rem 0;
  color: var(--text);
}
.radio input { width: auto; margin-top: 0.25rem; }

.code-block {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.code-block.log { max-height: 320px; }
.steps { color: var(--muted); padding-left: 1.2rem; }
.steps li { margin: 0.35rem 0; }
.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}
.panel-section { margin-top: 1.75rem; }
.panel-section h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }


.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  margin-top: 1.25rem;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.data-table th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table tr:last-child td { border-bottom: 0; }
.cell-desc {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
  max-width: 360px;
}
.actions { width: 1%; white-space: nowrap; }
.section-sub {
  margin: 1.25rem 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
}
input.mono, .mono, textarea.mono {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.85rem;
}
textarea.mono {
  width: 100%;
  resize: vertical;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 860px) {
  .page-admin { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar nav { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .sidebar-foot { display: flex; align-items: center; justify-content: space-between; }
  .stats { grid-template-columns: 1fr; }
  .stats-5 { grid-template-columns: 1fr 1fr; }
  .form-grid, .meta-grid { grid-template-columns: 1fr; }
  .admin-main { padding: 1.25rem; }
  .home-top, .home-hero { padding-left: 1.25rem; padding-right: 1.25rem; }
}
