:root {
  --bg: #f4f6f9;
  --bg-accent: #e8eef6;
  --side: #0f172a;
  --side-2: #1e293b;
  --side-text: #94a3b8;
  --side-active: #f8fafc;
  --panel: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: #eff6ff;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: linear-gradient(180deg, var(--bg-accent), var(--bg) 240px);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.side {
  background: linear-gradient(180deg, var(--side) 0%, #111827 100%);
  color: var(--side-text);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 0.35rem 0.5rem 0.85rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
.brand strong { display: block; color: #fff; font-size: 1rem; letter-spacing: -0.02em; }
.brand small { color: var(--side-text); font-size: 0.72rem; word-break: break-all; }
.brand-mark {
  width: 2.4rem; height: 2.4rem; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  color: #fff; font-weight: 700; flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.nav-section {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0.4rem 0.75rem;
}
.side nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; overflow: auto; }
.side nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--side-text);
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
}
.side nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.side nav a:hover, .side nav a.active {
  background: rgba(255,255,255,0.08);
  color: var(--side-active);
  text-decoration: none;
}
.side nav a.active {
  background: rgba(37, 99, 235, 0.22);
  color: #fff;
}
.side-foot {
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  padding-top: 1rem;
  display: grid;
  gap: 0.65rem;
}
.who { font-size: 0.82rem; color: #cbd5e1; padding: 0 0.35rem; }
.who span { display: block; color: #64748b; font-size: 0.72rem; margin-top: 0.15rem; }

.main { padding: 1.5rem 1.75rem 3rem; max-width: 1180px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.35rem;
}
.topbar h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  font-weight: 700;
}
.subtitle { color: var(--muted); margin: 0.3rem 0 0; font-size: 0.95rem; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: var(--accent-soft);
  opacity: 0.7;
}
.stat .label { color: var(--muted); font-size: 0.8rem; font-weight: 600; position: relative; z-index: 1; }
.stat .value { font-size: 1.7rem; font-weight: 700; margin-top: 0.25rem; letter-spacing: -0.03em; position: relative; z-index: 1; }
.stat .hint { color: var(--muted); font-size: 0.78rem; margin-top: 0.35rem; position: relative; z-index: 1; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.15rem;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.95rem;
}
.panel h2 { margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.panel .muted { color: var(--muted); font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.75rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
.mono { font-family: var(--mono); font-size: 0.84rem; }

.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-2); text-decoration: none; color: #fff; }
.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover { background: #f8fafc; color: var(--text); }
.btn-danger { background: var(--bad); }
.btn-danger:hover { background: #b91c1c; }
.btn-ok { background: var(--ok); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; border-radius: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

form.inline { display: inline; }
.form-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: end;
}
label { display: grid; gap: 0.35rem; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.2);
  border-color: var(--accent);
}
.row-end { display: flex; align-items: end; gap: 0.5rem; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}
.search {
  min-width: min(320px, 100%);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3-3'/%3E%3C/svg%3E") 0.75rem center no-repeat;
  padding-left: 2.2rem;
}

.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--accent-soft); color: var(--accent); }

.flash {
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  font-weight: 500;
}
.flash-ok { background: var(--ok-bg); border-color: #a7f3d0; color: #065f46; }
.flash-error { background: var(--bad-bg); border-color: #fecaca; color: #991b1b; }
.flash-warn { background: var(--warn-bg); border-color: #fde68a; color: #92400e; }

.status-list { display: grid; gap: 0.45rem; }
.status-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.65rem 0.8rem;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.progress {
  height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 0.55rem;
}
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #3b82f6, #2563eb); }

.dns-block, .log-block {
  background: #0b1220;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 1rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  max-height: 480px;
}
.copy-row { display: flex; gap: 0.5rem; align-items: start; }
.copy-row .dns-block { flex: 1; }

.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}
.empty strong { display: block; color: var(--text); margin-bottom: 0.35rem; }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(800px 400px at 10% 0%, rgba(37,99,235,0.12), transparent 60%),
    radial-gradient(700px 360px at 100% 100%, rgba(15,23,42,0.08), transparent 55%),
    var(--bg);
}
.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.75rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}
.auth-card .brand { border: 0; padding: 0 0 1rem; justify-content: center; }
.auth-card .brand strong { color: var(--text); text-align: center; }
.auth-card .brand small { text-align: center; color: var(--muted); }
.auth-card form { display: grid; gap: 0.9rem; }
.auth-note { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 1rem 0 0; }

.health-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 0.35rem;
}
.health-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(5,150,105,0.15); }
.health-dot.off { background: var(--bad); box-shadow: 0 0 0 3px rgba(220,38,38,0.12); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: relative; height: auto;
    border-bottom: 1px solid rgba(148,163,184,0.2);
  }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side nav a { padding: 0.55rem 0.7rem; }
  .main { padding: 1.15rem; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
}
