/* ============ Check HDK — modern dark UI ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #080b12;
  --bg-2: #0d1320;
  --panel: #111a29;
  --panel-2: #16202f;
  --border: rgba(255, 255, 255, 0.07);
  --border-2: rgba(255, 255, 255, 0.13);
  --text: #e8eefc;
  --muted: #8ea0bd;
  --muted-2: #5f7192;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.8);
  --grad: linear-gradient(120deg, #7c5cff, #22d3ee);
}

html, body { height: 100%; }

body {
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #24314a; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

a { color: var(--accent-2); text-decoration: none; }
code, pre { font-family: "Cascadia Code", Consolas, monospace; }

/* ---------------- Login ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.login-wrap::before, .login-wrap::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.35;
}
.login-wrap::before { width: 480px; height: 480px; background: #7c5cff; top: -160px; left: -120px; }
.login-wrap::after { width: 420px; height: 420px; background: #22d3ee; bottom: -160px; right: -120px; }

.login-card {
  position: relative; z-index: 1; width: 380px; max-width: calc(100vw - 32px);
  background: rgba(17, 26, 41, 0.72); backdrop-filter: blur(18px);
  border: 1px solid var(--border-2); border-radius: 20px; padding: 36px 30px;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 54px; height: 54px; border-radius: 16px; background: var(--grad);
  display: flex; align-items: center; justify-content: center; margin-bottom: 20px;
  box-shadow: 0 12px 30px -10px rgba(124, 92, 255, 0.7);
}
.login-logo svg { width: 28px; height: 28px; stroke: #fff; }
.login-card h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.login-card p.sub { color: var(--muted); margin: 6px 0 26px; font-size: 13px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 7px; text-transform: uppercase; letter-spacing: 0.4px; }

input, select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border-2);
  color: var(--text); border-radius: var(--radius-sm); padding: 11px 13px;
  font-size: 14px; font-family: inherit; outline: none; transition: border 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 16px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { border-color: var(--border-2); background: #1c2841; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--grad); filter: brightness(1.1); }
.btn-danger { color: #ffb4b4; border-color: rgba(239, 68, 68, 0.35); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.14); border-color: var(--red); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 11px; font-size: 12.5px; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-2); }

/* ---------------- App layout ---------------- */
.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }

.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 20px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 12px; background: var(--grad);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 10px 24px -10px rgba(124, 92, 255, 0.8);
}
.brand-logo svg { width: 20px; height: 20px; stroke: #fff; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }
.brand-sub { font-size: 11px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer; font-weight: 600; font-size: 13.5px; transition: all 0.14s;
  border: 1px solid transparent;
}
.nav-item svg { width: 18px; height: 18px; stroke: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(124, 92, 255, 0.18), rgba(34, 211, 238, 0.08)); color: #fff; border-color: rgba(124, 92, 255, 0.3); }
.nav-item .dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--panel-2); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent-2); border: 1px solid var(--border-2); }
.user-meta { flex: 1; min-width: 0; }
.user-meta b { display: block; font-size: 13px; }
.user-meta span { font-size: 11px; color: var(--muted); }

.main { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 62px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  gap: 14px; padding: 0 24px; background: rgba(13, 19, 32, 0.6); backdrop-filter: blur(8px); flex-shrink: 0;
}
.topbar h2 { font-size: 16px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border-2); font-size: 12px; color: var(--muted); font-weight: 600; }
.pill .led { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.off .led { background: var(--red); box-shadow: 0 0 8px var(--red); }

.view { flex: 1; overflow-y: auto; padding: 24px; }

/* ---------------- Cards / grid ---------------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: linear-gradient(180deg, var(--panel), rgba(17, 26, 41, 0.6));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title .spacer { flex: 1; }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -0.6px; }
.stat .value.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .hint { font-size: 12px; color: var(--muted-2); }
.stat-icon { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--panel-2); border: 1px solid var(--border-2); }
.stat-icon svg { width: 19px; height: 19px; }

.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-head h3 { font-size: 15px; font-weight: 700; }
.section-head .spacer { flex: 1; }

/* ---------------- List rows ---------------- */
.row {
  display: flex; align-items: center; gap: 14px; padding: 13px 15px; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--border); margin-bottom: 9px; transition: border 0.15s;
}
.row:hover { border-color: var(--border-2); }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.row .mono { font-family: "Cascadia Code", monospace; font-size: 12px; color: var(--muted); }
.row .actions { display: flex; gap: 7px; flex-shrink: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; border: 1px solid transparent; }
.badge.blue { background: rgba(59, 130, 246, 0.14); color: #7cb2ff; border-color: rgba(59, 130, 246, 0.3); }
.badge.purple { background: rgba(124, 92, 255, 0.16); color: #b3a2ff; border-color: rgba(124, 92, 255, 0.32); }
.badge.green { background: rgba(34, 197, 94, 0.14); color: #6ee7a8; border-color: rgba(34, 197, 94, 0.3); }
.badge.red { background: rgba(239, 68, 68, 0.14); color: #ff9d9d; border-color: rgba(239, 68, 68, 0.3); }
.badge.amber { background: rgba(245, 158, 11, 0.15); color: #ffce6b; border-color: rgba(245, 158, 11, 0.3); }
.badge.gray { background: rgba(142, 160, 189, 0.12); color: var(--muted); border-color: var(--border-2); }

.empty { text-align: center; color: var(--muted-2); padding: 34px 16px; font-size: 13.5px; }

/* ---------------- Toolbar / form inline ---------------- */
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.toolbar .field { margin-bottom: 0; }
.toolbar .field.grow { flex: 1; min-width: 220px; }

/* ---------------- Toggle switch ---------------- */
.switch { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--border); cursor: pointer; }
.switch:hover { border-color: var(--border-2); }
.switch .txt { flex: 1; }
.switch .txt b { display: block; font-size: 13.5px; }
.switch .txt span { font-size: 12px; color: var(--muted); }
.track { width: 42px; height: 24px; border-radius: 999px; background: #29344a; position: relative; transition: 0.2s; flex-shrink: 0; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: 0.2s; }
.switch.on .track { background: var(--green); }
.switch.on .track::after { transform: translateX(18px); }

/* ---------------- Alerts feed ---------------- */
.feed { display: flex; flex-direction: column; gap: 9px; max-height: 420px; overflow-y: auto; }
.alert-row { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--muted); }
.alert-row.rot { border-left-color: var(--amber); }
.alert-row.back { border-left-color: var(--green); }
.alert-row.dead { border-left-color: var(--red); }
.alert-row .a-body { flex: 1; min-width: 0; }
.alert-row .a-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.alert-row .a-top b { font-size: 13.5px; }
.alert-row .a-time { font-size: 11.5px; color: var(--muted-2); }
.alert-row .a-ch { font-size: 12px; color: var(--muted); margin-top: 3px; }
.alert-row pre { margin-top: 8px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 140px; overflow: auto; color: #cdd8ec; }

/* ---------------- Toast ---------------- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: 340px; max-width: calc(100vw - 36px); }
.toast { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 13px 15px; box-shadow: var(--shadow); animation: slideIn 0.25s ease; border-left: 3px solid var(--accent); }
.toast.rot { border-left-color: var(--amber); }
.toast.back { border-left-color: var(--green); }
.toast.dead { border-left-color: var(--red); }
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
.toast b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.toast span { font-size: 12.5px; color: var(--muted); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* ---------------- Modal ---------------- */
.overlay { position: fixed; inset: 0; background: rgba(4, 7, 12, 0.7); backdrop-filter: blur(4px); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 24px; animation: fade 0.15s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 640px; max-width: 100%; max-height: 86vh; overflow: hidden; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border-2); border-radius: 18px; box-shadow: var(--shadow); animation: pop 0.18s; }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15.5px; font-weight: 700; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.x-btn { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 8px; display: flex; }
.x-btn:hover { background: var(--panel-2); color: var(--text); }
.x-btn svg { width: 18px; height: 18px; stroke: currentColor; }

.ngon { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; }
.ngon .n-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.ngon pre { font-size: 12.5px; white-space: pre-wrap; word-break: break-word; color: #cdd8ec; max-height: 180px; overflow: auto; }

.spin { width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; z-index: 80; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: none; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .menu-btn { display: flex !important; }
}
.menu-btn { display: none; background: transparent; border: 1px solid var(--border-2); border-radius: 9px; padding: 8px; cursor: pointer; color: var(--text); }
.menu-btn svg { width: 18px; height: 18px; stroke: currentColor; }
