:root {
  --bg: #0f1412;
  --bg-elevated: #171d1a;
  --bg-panel: #1c2420;
  --bg-hover: #24302a;
  --line: rgba(180, 210, 195, 0.12);
  --text: #e8f0ea;
  --muted: #8fa399;
  --accent: #3dba8a;
  --accent-2: #c9e86a;
  --accent-dim: rgba(61, 186, 138, 0.16);
  --danger: #e8786a;
  --warn: #e0b35a;
  --ok: #3dba8a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --font: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 186, 138, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(201, 232, 106, 0.08), transparent 50%),
    linear-gradient(160deg, #0c110f 0%, #121916 45%, #0e1311 100%);
  min-height: 100vh;
}

button, input { font: inherit; }
button { cursor: pointer; }

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

.sidebar {
  padding: 28px 18px;
  border-right: 1px solid var(--line);
  background: rgba(15, 20, 18, 0.72);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, var(--accent), #2a8f6c 55%, var(--accent-2));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 8px 24px rgba(61,186,138,0.35);
  animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.04); filter: brightness(1.08); }
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent-2);
}
.nav-icon { opacity: 0.8; }

.sidebar-foot {
  margin-top: auto;
  padding: 8px;
  display: grid;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(61,186,138,0.12);
  color: var(--accent);
  border: 1px solid rgba(61,186,138,0.25);
}
.status-pill.bad {
  background: rgba(232,120,106,0.12);
  color: var(--danger);
  border-color: rgba(232,120,106,0.25);
}

.main {
  padding: 28px 36px 48px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}
.topbar h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.muted { color: var(--muted); margin: 0; font-size: 14px; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.view { display: none; animation: fadeIn 0.28s ease; }
.view.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.stat {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.stat strong { color: var(--text); font-weight: 600; margin-right: 4px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%), var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: rgba(61, 186, 138, 0.35);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}
.card-desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.badge {
  flex-shrink: 0;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge.running {
  color: var(--ok);
  background: rgba(61,186,138,0.12);
  border-color: rgba(61,186,138,0.28);
}
.badge.stopped {
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border-color: var(--line);
}
.badge.missing {
  color: var(--danger);
  background: rgba(232,120,106,0.12);
  border-color: rgba(232,120,106,0.28);
}
.badge.enabled {
  color: var(--accent-2);
  background: rgba(201,232,106,0.1);
  border-color: rgba(201,232,106,0.28);
}
.badge.disabled {
  color: var(--warn);
  background: rgba(224,179,90,0.1);
  border-color: rgba(224,179,90,0.28);
}

.meta {
  display: grid;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.meta code, .path {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #b7c9bc;
  word-break: break-all;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--muted);
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tool-chip {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--accent-dim);
  color: #9fe0c2;
  border: 1px solid rgba(61,186,138,0.2);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, #36b482, #2a9a6d);
  border-color: transparent;
  color: #04140e;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger {
  color: #ffd0c9;
  border-color: rgba(232,120,106,0.35);
  background: rgba(232,120,106,0.1);
}
.btn.ghost {
  background: transparent;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  border: 0;
  padding: 0;
  transition: background 0.2s;
}
.switch.on { background: var(--accent); }
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
}
.switch.on::after { transform: translateX(18px); }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  min-width: 220px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #1e2a24;
  border: 1px solid rgba(61,186,138,0.35);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  animation: fadeIn 0.2s ease;
}
.toast.error {
  border-color: rgba(232,120,106,0.45);
  background: #2a1c1a;
}

.dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 720px;
  width: calc(100% - 32px);
}
.dialog::backdrop {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}
.dialog-panel {
  margin: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.dialog-panel header,
.dialog-panel footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
}
.dialog-panel h2 { margin: 0; font-size: 16px; }
.dialog-panel pre {
  margin: 0;
  padding: 16px;
  max-height: 50vh;
  overflow: auto;
  background: #0b100e;
  color: #c7dbcfd0;
  font-size: 12px;
  line-height: 1.5;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px;
    gap: 16px;
  }
  .nav { flex-direction: row; }
  .sidebar-foot { display: none; }
  .main { padding: 20px 16px 40px; }
  .grid { grid-template-columns: 1fr; }
}
