:root {
  --bg: #0b1120;
  --bg-elevated: #111827;
  --bg-card: #161f33;
  --border: #26334d;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
}

.brand-title { font-weight: 700; font-size: 17px; }
.brand-domain { font-size: 12px; color: var(--info); font-family: monospace; }

.nav-menu { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: all 0.15s ease;
}
.nav-item:hover { background: rgba(59, 130, 246, 0.1); color: var(--text); }
.nav-item.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.4);
  color: #fff;
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.topbar {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.select-router, .input, .textarea {
  background: #0d1526;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
}
.select-router { width: auto; min-width: 240px; }
.input:focus, .textarea:focus, .select-router:focus {
  outline: none;
  border-color: var(--primary);
}
.code-textarea { font-family: "JetBrains Mono", Consolas, monospace; font-size: 13px; }

.content { padding: 24px; flex: 1; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.section-header h1 { margin: 0 0 4px 0; font-size: 22px; }
h3 { margin: 0 0 12px 0; font-size: 16px; }
h4 { margin: 0 0 8px 0; font-size: 14px; color: var(--info); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

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

.stat-value { font-size: 20px; font-weight: 700; margin: 6px 0; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.progress { width: 100%; height: 8px; background: #0d1526; border-radius: 99px; overflow: hidden; margin: 6px 0; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--success), var(--info)); transition: width 0.3s ease; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
  transition: background 0.15s ease;
}
.btn:hover { background: var(--primary-hover); }
.btn-secondary { background: #24324d; color: var(--text); }
.btn-secondary:hover { background: #2f4062; }
.btn-success { background: #059669; }
.btn-success:hover { background: #047857; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.badge, .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #1e293b;
  border: 1px solid var(--border);
}
.badge-online, .badge-success { background: rgba(16, 185, 129, 0.18); color: #34d399; border-color: rgba(16, 185, 129, 0.4); }
.badge-offline, .badge-danger { background: rgba(239, 68, 68, 0.18); color: #f87171; border-color: rgba(239, 68, 68, 0.4); }
.badge-warning { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border-color: rgba(245, 158, 11, 0.4); }
.badge-info { background: rgba(6, 182, 212, 0.18); color: #22d3ee; border-color: rgba(6, 182, 212, 0.4); }
.pill-domain { font-size: 11px; color: var(--info); justify-content: center; }

.preset-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: #162238;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { border-color: var(--primary); background: rgba(59, 130, 246, 0.16); }

.table-wrap { overflow-x: auto; max-height: 320px; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table th { color: var(--muted); font-weight: 600; background: #121a2d; position: sticky; top: 0; }

.code-box {
  background: #090e1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  overflow-x: auto;
  max-height: 240px;
  margin: 0;
  white-space: pre-wrap;
}

.terminal-card { padding: 0; overflow: hidden; }
.terminal-screen {
  background: #050811;
  color: #a7f3d0;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  padding: 16px;
  height: 430px;
  overflow-y: auto;
  margin: 0;
  white-space: pre-wrap;
}
.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #0d1526;
  border-top: 1px solid var(--border);
}
.terminal-prompt { font-family: monospace; color: var(--info); font-weight: 700; white-space: nowrap; }
.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: monospace;
  font-size: 14px;
}
.terminal-input:focus { outline: none; }

.chat-box {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0d1526;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.chat-msg { padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.chat-msg.user { background: rgba(59, 130, 246, 0.16); align-self: flex-end; max-width: 90%; }
.chat-msg.assistant { background: #17233b; align-self: flex-start; max-width: 95%; }

.exec-results { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.exec-step { padding: 8px 10px; border-radius: 8px; background: #0d1526; border-left: 3px solid var(--success); font-family: monospace; font-size: 12px; }
.exec-step.fail { border-left-color: var(--danger); }

.warning-box {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fcd34d;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 10px;
}
.hidden { display: none; }

.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.form-group label { font-size: 12px; color: var(--muted); font-weight: 600; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.bullet-list { margin: 6px 0; padding-left: 18px; font-size: 13px; color: var(--text); }

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

.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #17233b;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; align-items: center; }
  .nav-menu { flex-direction: row; }
  .sidebar-footer { display: none; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
}
