:root {
  --bg: #0f1722;
  --bg-2: #17202f;
  --bg-3: #1e2a3a;
  --border: #2b3a4d;
  --text: #e6edf3;
  --text-dim: #8ba3b8;
  --accent: #2f9e6e;
  --accent-2: #1f7a52;
  --danger: #e05555;
  --warn: #e0a13c;
  --info: #4f9cf0;
  --ok: #2f9e6e;
  --radius: 8px;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 20px;
  height: 56px;
  background: linear-gradient(180deg, #1a2536, #131b28);
  border-bottom: 1px solid var(--border);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 11px; color: var(--text-dim); }

.nav { display: flex; gap: 4px; flex: 1; }

.nav a {
  color: var(--text-dim);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--bg-3); color: var(--text); }
.nav a.active { background: rgba(47, 158, 110, 0.15); color: var(--accent); }

.conn { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); }
.conn.online .conn-dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.conn.offline .conn-dot { background: var(--danger); }
.conn.pending .conn-dot { background: var(--warn); }

/* ---------- content ---------- */
.content {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 4px; font-size: 22px; }
.page-head .sub { margin: 0; color: var(--text-dim); font-size: 13px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-3);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s, background 0.15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent-2); color: #fff; }
.btn-danger { background: rgba(224, 85, 85, 0.12); border-color: rgba(224, 85, 85, 0.5); color: var(--danger); }
.btn-ghost { background: transparent; }

.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }

/* ---------- cards ---------- */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 15px; color: var(--text); }

/* ---------- stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat .label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; }
.stat .value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.stat .value.ok { color: var(--ok); }
.stat .value.warn { color: var(--warn); }
.stat .value.bad { color: var(--danger); }
.stat .value.info { color: var(--info); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-2);
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-3); }
.data-table .mono { font-family: var(--mono); font-size: 12.5px; }
.table-empty { padding: 26px; text-align: center; color: var(--text-dim); }

/* ---------- badges / chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}
.chip.ok { background: rgba(47, 158, 110, 0.15); color: #4fd59a; border-color: rgba(47, 158, 110, 0.4); }
.chip.warn { background: rgba(224, 161, 60, 0.15); color: #edb46a; border-color: rgba(224, 161, 60, 0.4); }
.chip.err { background: rgba(224, 85, 85, 0.15); color: #f07d7d; border-color: rgba(224, 85, 85, 0.4); }
.chip.info { background: rgba(79, 156, 240, 0.15); color: #7db4f7; border-color: rgba(79, 156, 240, 0.4); }
.chip.dim { background: var(--bg-3); color: var(--text-dim); border-color: var(--border); }

/* ---------- inputs ---------- */
input[type="text"], input[type="number"], input[type="file"], input[type="password"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
::placeholder { color: var(--text-dim); }

.filter-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { width: auto; flex: 1; min-width: 140px; }

/* ---------- progress ---------- */
.progress { height: 8px; border-radius: 999px; background: var(--bg-3); overflow: hidden; min-width: 110px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 0.4s; }
.progress.pulse > div { background: linear-gradient(90deg, var(--info), var(--accent)); }

/* ---------- upload dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.drag { border-color: var(--accent); background: rgba(47, 158, 110, 0.08); color: var(--text); }
.dropzone .dz-file { color: var(--text); font-family: var(--mono); word-break: break-all; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 18, 0.65);
  z-index: 50;
}
.modal {
  position: fixed;
  z-index: 51;
  top: 8vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  max-height: 84vh;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.form-row { margin-bottom: 14px; }
.modal .form-row { margin-bottom: 14px; }
.modal .form-row label { display: block; margin-bottom: 5px; font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.modal .form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  min-width: 260px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  animation: slide-in 0.18s ease;
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.warn { border-left: 3px solid var(--warn); }
.toast.info { border-left: 3px solid var(--info); }
.toast.out { opacity: 0; transform: translateY(6px); transition: 0.25s; }

@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- misc ---------- */
.subtext { color: var(--text-dim); font-size: 12px; }
.mono { font-family: var(--mono); }
.time { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.row-checkbox { display: grid; place-items: center; justify-content: center; }
.muted-row td { opacity: 0.55; }
.select-all { font-size: 12.5px; color: var(--text-dim); cursor: pointer; user-select: none; }
.pick-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-3); }
.pick-list label { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; }
.pick-list label:last-child { border-bottom: none; }
.pick-list input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.pick-list .hint { margin-left: auto; color: var(--text-dim); font-size: 11.5px; }

.toolbar-tools { display: flex; gap: 6px; }
.btn.icon-only { padding: 6px 9px; }

/* ---------- auth / login ---------- */
body.auth-none .nav,
body.auth-none .conn,
body.auth-none .user-chip { display: none !important; }

.user-chip { display: flex; align-items: center; gap: 8px; }
.user-name {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 600;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-wrap { min-height: calc(100vh - 120px); display: grid; place-items: center; }
.login-card {
  width: min(360px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 26px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-brand strong { font-size: 16px; }
.login-brand > div { display: flex; flex-direction: column; line-height: 1.15; }
.login-brand > div span { font-size: 11px; color: var(--text-dim); }
.login-hint { margin-top: 14px; text-align: center; }