/* Krux.it Modular Admin Panel — Dark-Mode First Design System (Zero JS / Zero Build CSS) */
:root {
  --bg: #080a0f;
  --bg-elev: #0f131d;
  --bg-card: #131926;
  --bg-input: #0b0f17;
  --border: #222b3d;
  --border-strong: #2f3b54;
  --text: #e6edf7;
  --text-muted: #8b9bb4;
  --cyan: #22d3ee;
  --cyan-strong: #06b6d4;
  --emerald: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --nodefy: #8b5cf6;
  --nodefy-soft: rgba(139, 92, 246, 0.14);
  --nodefy-border: rgba(139, 92, 246, 0.42);
  --radius: 10px;
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", ui-monospace, SFMono-Regular, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--cyan);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 5px;
  padding: 1px 5px;
  color: #cbd5e1;
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.mt-xs { margin-top: 6px; }
.mt-sm { margin-top: 12px; }
.mt-md { margin-top: 20px; }

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--cyan-strong), #2563eb);
  color: #041019;
  font-weight: 800;
  font-size: 18px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 22px rgba(6, 182, 212, 0.25);
}

.brand-name {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.06em;
  line-height: 1.1;
}

.brand-name .accent { color: var(--cyan); }

.brand-sub {
  font-size: 10px;
  letter-spacing: 0.11em;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.nav-section-label {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0 10px 6px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  color: #c2d0e6;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
}

.nav-item.is-active {
  background: rgba(34, 211, 238, 0.1);
  border-color: rgba(34, 211, 238, 0.28);
  color: var(--cyan);
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan-strong);
  flex-shrink: 0;
}

.nav-dot.dot-nodefy {
  background: var(--nodefy);
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.7);
}

.nav-text { flex: 1; }

.nav-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.12);
  color: var(--cyan);
}

.nav-pill.pill-nodefy {
  background: var(--nodefy-soft);
  color: #c4b5fd;
  border: 1px solid var(--nodefy-border);
}

.sidebar-nodefy-card {
  background: linear-gradient(160deg, rgba(139, 92, 246, 0.14), rgba(15, 19, 29, 0.95));
  border: 1px solid var(--nodefy-border);
  border-radius: var(--radius);
  padding: 13px;
}

.nodefy-kicker {
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  color: #c4b5fd;
  font-weight: 700;
}

.nodefy-title {
  font-weight: 700;
  font-size: 15px;
  margin-top: 3px;
}

.nodefy-domain {
  font-family: var(--font-mono);
  color: #a78bfa;
  font-size: 12px;
}

.nodefy-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 0 10px;
}

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

.link-nodefy { color: #c4b5fd; font-weight: 600; }

.sidebar-user {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-name { font-weight: 700; }
.user-email { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }

/* Main area */
.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.status-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.content {
  padding: 22px 26px 40px;
  max-width: 1480px;
  width: 100%;
}

/* Cards & Grids */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card-nodefy {
  border-color: var(--nodefy-border);
  background: linear-gradient(155deg, rgba(139, 92, 246, 0.1), var(--bg-card) 60%);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card h2, .card h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card { padding: 16px 18px; }
.kpi-nodefy { border-color: var(--nodefy-border); }

.kpi-label {
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  margin: 6px 0 4px;
  font-family: var(--font-mono);
}

.kpi-sub {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-foot { font-size: 12px; color: var(--text-muted); }

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.banner-nodefy {
  background: linear-gradient(120deg, rgba(139, 92, 246, 0.18), rgba(6, 182, 212, 0.09) 65%, var(--bg-card));
  border: 1px solid var(--nodefy-border);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.banner-nodefy h2, .banner-nodefy h3 {
  margin: 8px 0 6px;
}

.banner-nodefy-left { max-width: 780px; }
.banner-nodefy-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Tables */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
}

.data-table td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(34, 43, 61, 0.6);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.progress-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  margin: 5px 0;
  overflow: hidden;
  max-width: 170px;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan-strong), var(--emerald));
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-cyan { background: rgba(34, 211, 238, 0.14); color: var(--cyan); border-color: rgba(34, 211, 238, 0.35); }
.badge-emerald { background: rgba(16, 185, 129, 0.15); color: #34d399; border-color: rgba(16, 185, 129, 0.35); }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border-color: rgba(245, 158, 11, 0.35); }
.badge-red { background: rgba(239, 68, 68, 0.15); color: #f87171; border-color: rgba(239, 68, 68, 0.35); }
.badge-violet, .badge-nodefy { background: var(--nodefy-soft); color: #c4b5fd; border-color: var(--nodefy-border); }
.badge-muted { background: rgba(148, 163, 184, 0.12); color: var(--text-muted); border-color: rgba(148, 163, 184, 0.24); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  transition: filter 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  text-decoration: none;
}

.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, var(--cyan-strong), #0284c7);
  border-color: transparent;
  color: #03121c;
}

.btn-nodefy {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border-color: rgba(167, 139, 250, 0.4);
  color: #ffffff;
}

.btn-emerald { background: rgba(16, 185, 129, 0.18); border-color: rgba(16, 185, 129, 0.45); color: #6ee7b7; }
.btn-amber { background: rgba(245, 158, 11, 0.18); border-color: rgba(245, 158, 11, 0.45); color: #fcd34d; }
.btn-red { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.45); color: #fca5a5; }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost { background: rgba(255, 255, 255, 0.04); border-color: transparent; color: #cbd5e1; }

.action-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.action-group form { margin: 0; }

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 11px;
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font-sans);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--cyan-strong);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.18);
}

.select-sm { padding: 4px 8px; font-size: 12px; }
.mono-input { font-family: var(--font-mono); letter-spacing: 0.12em; }

.form-stack { display: flex; flex-direction: column; gap: 13px; }
.form-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.checkbox-field {
  grid-column: span 3;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.form-actions { display: flex; align-items: flex-end; }

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

.filter-bar input { min-width: 220px; flex: 1; }

/* Alerts */
.alert {
  margin: 14px 26px 0;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid transparent;
}

.auth-card .alert, .card .alert { margin: 12px 0; }

.alert-ok {
  background: rgba(16, 185, 129, 0.13);
  border-color: rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
}

.alert-err {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.42);
  color: #fecaca;
}

/* Console WebSocket Terminal */
.console-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.switch-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.switch-chip.is-active {
  border-color: var(--cyan-strong);
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
}

.dot-status { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.dot-running { background: var(--emerald); }
.dot-crashed { background: var(--red); }
.dot-starting, .dot-stopping { background: var(--amber); }

.console-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}

.console-card { padding: 16px; }

.console-terminal {
  background: #05070b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  height: 460px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
}

.console-line { word-break: break-word; }
.log-ts { color: #64748b; }
.log-src { color: #94a3b8; }
.log-info .log-lvl { color: var(--cyan); }
.log-warn .log-lvl { color: var(--amber); }
.log-err .log-lvl { color: var(--red); }
.log-cmd .log-lvl { color: var(--emerald); }
.log-cmd .log-msg { color: #6ee7b7; font-weight: 600; }
.log-nodefy .log-lvl, .log-nodefy .log-msg { color: #c4b5fd; }

.console-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  background: #05070b;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 10px;
}

.console-prompt {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cyan);
  white-space: nowrap;
}

.console-input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-family: var(--font-mono) !important;
  padding: 6px 4px !important;
}

.console-readonly-bar {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
  font-size: 12.5px;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.tele-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tele-label { font-size: 10.5px; font-family: var(--font-mono); color: var(--text-muted); }
.tele-box strong { font-family: var(--font-mono); font-size: 15px; }
.tele-sub { font-size: 11px; color: var(--text-muted); }

/* Audit Feed & Modules */
.audit-feed { display: flex; flex-direction: column; gap: 10px; }

.audit-feed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.audit-action { margin-left: 6px; }
.audit-time { font-size: 11.5px; color: var(--text-muted); }
.meta-json { font-size: 11px; display: inline-block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.module-grid, .preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.module-card, .preset-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.module-card-nodefy {
  border-color: var(--nodefy-border);
  background: linear-gradient(155deg, rgba(139, 92, 246, 0.12), var(--bg-input));
}

.module-planned {
  border-style: dashed;
  opacity: 0.88;
}

.module-top, .module-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.module-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid rgba(34, 43, 61, 0.6); }

/* 2FA & Auth */
.totp-box { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.qr-frame { padding: 8px; background: #0d111a; border: 1px solid var(--border-strong); border-radius: 8px; }
.secret-code { display: inline-block; padding: 6px 10px; font-size: 13px; letter-spacing: 0.08em; color: var(--cyan); word-break: break-all; }
.bullet-list { margin: 10px 0 0; padding-left: 18px; color: var(--text-muted); font-size: 13px; }
.bullet-list li { margin-bottom: 5px; }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(6, 182, 212, 0.14), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.14), transparent 40%),
    var(--bg);
  padding: 20px;
}

.auth-wrapper { width: 100%; max-width: 440px; }

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.auth-brand { margin-bottom: 20px; }
.auth-title { margin: 0 0 6px; font-size: 20px; }

.auth-footer-nodefy {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 1120px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid, .console-layout { grid-template-columns: 1fr; }
  .module-grid, .preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checkbox-field { grid-column: span 2; }
}

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .module-grid, .preset-grid, .kpi-grid, .grid-form { grid-template-columns: 1fr; }
  .checkbox-field { grid-column: span 1; }
}
