:root {
  --bg-0: #07080d;
  --bg-1: #0d0e15;
  --bg-2: #11131c;
  --bg-3: #161824;
  --border: #1f2230;
  --border-strong: #2a2e40;
  --text: #e8e9f0;
  --text-mid: #b4b7c4;
  --text-muted: #6e7185;

  --accent: #6e8df5;
  --accent-2: #8b71f7;
  --accent-soft: rgba(110, 141, 245, 0.12);
  --accent-strong: rgba(110, 141, 245, 0.35);

  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.12);
  --yellow: #fbbf24;
  --yellow-soft: rgba(251, 191, 36, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);

  --sidebar-width: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}
.brand-title {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.brand-subtitle {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  margin-top: -2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-item {
  background: transparent;
  border: none;
  color: var(--text-mid);
  font: inherit;
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-weight: 500;
}
.nav-item:hover {
  background: var(--bg-2);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent-strong);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.2s;
}
.dot.green { background: var(--green); box-shadow: 0 0 6px rgba(74, 222, 128, 0.45); }
.dot.yellow { background: var(--yellow); }
.dot.red { background: var(--red); }

/* ==================== MAIN ==================== */
.main {
  padding: 28px 36px 60px;
  max-width: 1500px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.topbar h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.topbar-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}
.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ==================== BUTTONS ==================== */
.btn {
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  transition: all 0.15s;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-2); border-color: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
.btn-small { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, #5b7ce6 100%);
  border-color: rgba(255, 255, 255, 0.06);
  color: white;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset, 0 4px 14px rgba(110, 141, 245, 0.3);
}
.btn-primary:hover { filter: brightness(1.08); border-color: rgba(255, 255, 255, 0.12); }
.btn-secondary { background: var(--bg-2); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-2); }
.btn-danger {
  background: var(--red-soft);
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--red);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.18); }
.btn-success {
  background: var(--green-soft);
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--green);
}
.btn-success:hover { background: rgba(74, 222, 128, 0.18); }

.result-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 7px;
  background: var(--bg-2);
  color: var(--text-mid);
  border: 1px solid var(--border);
  min-height: 28px;
  display: inline-flex;
  align-items: center;
}
.result-chip.ok { background: var(--green-soft); color: var(--green); border-color: rgba(74, 222, 128, 0.3); }
.result-chip.fail { background: var(--red-soft); color: var(--red); border-color: rgba(248, 113, 113, 0.3); }

/* ==================== TABS / CONTENT ==================== */
.tab-content { display: none; animation: fadeIn 0.2s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ==================== STAT CARDS ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color 0.2s;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { border-color: var(--border-strong); }
.stat-card.accent {
  background: linear-gradient(140deg, var(--bg-1) 0%, rgba(110, 141, 245, 0.08) 100%);
  border-color: var(--accent-strong);
}
.stat-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-unit {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 2px;
}
.stat-foot {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 4px;
}
.stat-foot span { color: var(--text-mid); font-weight: 500; }

/* ==================== PANELS ==================== */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.panel h3 {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}
.panel-header h3 { margin-bottom: 0; }
.row-controls { display: flex; gap: 10px; align-items: center; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.muted { color: var(--text-muted); font-size: 13px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 12px;
}
.section-title h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.section-title:first-child { margin-top: 0; }
.muted-tag {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-2);
  padding: 3px 8px;
  border-radius: 5px;
  font-weight: 500;
}

/* ==================== DOMAIN LIST ==================== */
.domain-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.domain-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.domain-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-mid);
  min-width: 0;
  flex: 0 0 auto;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.domain-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-2);
  border-radius: 3px;
  overflow: hidden;
}
.domain-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.domain-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  min-width: 50px;
  text-align: right;
}

/* ==================== ACTIVE SESSIONS ==================== */
.active-sessions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.session-pill {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(74, 222, 128, 0.3);
  padding: 5px 12px;
  border-radius: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.session-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 4px rgba(74, 222, 128, 0.6);
}

/* ==================== LOGS ==================== */
.logs {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 540px;
  overflow-y: auto;
  padding: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
}
.logs::-webkit-scrollbar { width: 8px; }
.logs::-webkit-scrollbar-track { background: transparent; }
.logs::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.log-line {
  padding: 1px 4px;
  white-space: pre-wrap;
  word-break: break-all;
  border-radius: 3px;
}
.log-line:hover { background: var(--bg-2); }
.log-time { color: var(--text-muted); margin-right: 10px; }
.log-text { color: var(--text-mid); }
.log-error .log-text { color: var(--red); }
.log-warn .log-text { color: var(--yellow); }

/* ==================== FORMS ==================== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-row.span-2 { grid-column: 1 / -1; }
.form-row label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
.form-row input[type="text"],
.form-row input[type="number"],
.form-row select,
.form-row textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-3);
}
.form-row textarea {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  resize: vertical;
  min-height: 60px;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-mid);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.checkbox-inline input { width: 14px; height: 14px; accent-color: var(--accent); }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ==================== TARGETS ==================== */
.target-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.target-card:hover { border-color: var(--border-strong); }
.target-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.target-grid .span-2 { grid-column: 1 / -1; }
.target-field { display: flex; flex-direction: column; gap: 5px; }
.target-field label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.target-field .hint-inline { font-size: 10px; color: var(--text-muted); text-transform: none; }
.target-field input, .target-field textarea {
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}
.target-field input:focus, .target-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.target-field textarea { resize: vertical; min-height: 50px; }
.target-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ==================== TABLE ==================== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-2);
}
tr:hover td { background: var(--bg-2); }
.status-200 { color: var(--green); font-weight: 500; }
.status-300 { color: var(--yellow); font-weight: 500; }
.status-400, .status-500 { color: var(--red); font-weight: 500; }

/* ==================== MISC ==================== */
code {
  background: var(--bg-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  border: 1px solid var(--border);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 14px;
    padding: 14px;
  }
  .sidebar-footer { border: none; border-left: 1px solid var(--border); padding: 0 0 0 14px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .target-grid { grid-template-columns: 1fr; }
}
