:root {
  --bg: #0d0f14;
  --bg-soft: #12151d;
  --card: #171b24;
  --card-2: #1d2230;
  --line: #2a3040;
  --text: #e7eaf3;
  --muted: #8d95a9;
  --accent: #8b9cff;
  --accent-2: #b18cff;
  --danger: #ff6b81;
  --ok: #58d6a0;
  --warn: #ffcc66;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #1b2140 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
}

a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 15, 20, 0.75);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-weight: 800;
  font-size: 18px;
  color: #0d0f14;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 20px rgba(139, 156, 255, 0.25);
}

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

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }

.tab {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  transition: 0.15s ease;
}

.tab:hover { color: var(--text); border-color: #3a4358; }
.tab.active {
  color: #0d0f14;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 600;
}

.panel { display: none; }
.panel.active { display: block; animation: fade 0.18s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.grid { display: grid; gap: 14px; }
.cards { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.section { margin-top: 16px; }

.card-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.card-value { font-size: 20px; font-weight: 650; margin: 6px 0 2px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }

h2 { font-size: 15px; margin: 0 0 14px; letter-spacing: 0.2px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.form-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.field.grow { flex: 1 1 320px; }
.field span { color: var(--muted); font-size: 12px; }

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f1218;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 156, 255, 0.15); }

.btn {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  transition: 0.15s ease;
  white-space: nowrap;
}

.btn:hover { border-color: #46506a; transform: translateY(-1px); }
.btn:active { transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0d0f14; border-color: transparent; font-weight: 650; }
.btn-danger { color: var(--danger); border-color: rgba(255, 107, 129, 0.35); }
.btn-danger:hover { background: rgba(255, 107, 129, 0.1); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; padding-bottom: 10px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #2a3040;
  border: 1px solid var(--line);
  position: relative;
  transition: 0.15s ease;
}
.switch-dot {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: 0.15s ease;
}
.switch input:checked + .switch-track { background: rgba(88, 214, 160, 0.25); border-color: rgba(88, 214, 160, 0.5); }
.switch input:checked + .switch-track .switch-dot { left: 23px; background: var(--ok); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
tbody tr:hover { background: rgba(139, 156, 255, 0.04); }
td.mono, .mono { font-family: var(--mono); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.ok { color: var(--ok); border-color: rgba(88, 214, 160, 0.4); background: rgba(88, 214, 160, 0.08); }
.badge.err { color: var(--danger); border-color: rgba(255, 107, 129, 0.4); background: rgba(255, 107, 129, 0.08); }
.badge.warn { color: var(--warn); border-color: rgba(255, 204, 102, 0.4); background: rgba(255, 204, 102, 0.08); }

.logs {
  margin: 0;
  padding: 14px;
  background: #090b0f;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #c7cede;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  max-height: 380px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { border-color: rgba(88, 214, 160, 0.5); }
.toast.err { border-color: rgba(255, 107, 129, 0.5); }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.login-brand { margin-bottom: 22px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-error { min-height: 18px; color: var(--danger); font-size: 13px; }

@media (max-width: 640px) {
  .topbar { padding: 14px 16px; }
  .wrap { padding: 16px 12px 48px; }
  .card { padding: 14px; }
  .row-actions { width: 100%; }
  .row-actions .btn { flex: 1; }
}
