:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --text-muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem 1.5rem;
  font-weight: 600;
  font-size: 1.1rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.nav-item {
  display: block;
  padding: 0.75rem 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s;
}

.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--primary); background: rgba(59,130,246,0.1); border-left: 3px solid var(--primary); }

.content { flex: 1; padding: 1.5rem 2rem; overflow-y: auto; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.header h1 { font-size: 1.5rem; font-weight: 600; }

.header-actions { display: flex; gap: 0.5rem; align-items: center; }

.api-key-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  color: var(--text);
  width: 220px;
}

.btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }

.page { display: none; }
.page.active { display: block; }

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.status-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.status-value { font-weight: 600; font-size: 1rem; }
.status-value.ok { color: var(--success); }
.status-value.fail { color: var(--danger); }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.metric-card h3 { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.metric-bar { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; margin-bottom: 0.5rem; }
.metric-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; }
.metric-big { font-size: 2rem; font-weight: 700; color: var(--primary); }

.actions-row { display: flex; gap: 0.75rem; }

.toolbar { margin-bottom: 1rem; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.data-table th, .data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th { background: var(--surface2); color: var(--text-muted); font-size: 0.85rem; }
.data-table tr:last-child td { border-bottom: none; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 600px;
}

.form-card label { display: block; margin: 1rem 0 0.35rem; font-size: 0.9rem; color: var(--text-muted); }
.form-card label:first-child { margin-top: 0; }

.form-card input, .form-card select, .form-card textarea {
  width: 100%;
  padding: 0.6rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
}

.form-card button { margin-top: 1rem; }

.result-box, .logs-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.logs-box { max-height: 500px; overflow-y: auto; font-family: monospace; }

.hidden { display: none !important; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tab { padding: 0.5rem 1rem; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-muted); cursor: pointer; }
.tab.active { background: var(--primary); color: white; border-color: var(--primary); }

.test-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }

.code-block {
  background: var(--bg);
  padding: 1rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  overflow-x: auto;
  margin: 1rem 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-width: 360px;
}

.modal-content h3 { margin-bottom: 1rem; }
.modal-content input { width: 100%; padding: 0.6rem; margin-bottom: 0.75rem; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

.modal-content.modal-wide { min-width: 440px; }
.hint { font-size: 0.85rem; color: var(--text-muted); margin: 0.5rem 0; }

.dns-list { margin-top: 1rem; }
.dns-record {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}
.dns-record-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.dns-type { background: var(--primary); color: white; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.dns-name { font-family: monospace; color: var(--text); }
.dns-value { font-family: monospace; font-size: 0.85rem; background: var(--bg); padding: 0.75rem; border-radius: 6px; word-break: break-all; margin: 0.5rem 0; }
.dns-desc { font-size: 0.85rem; color: var(--text-muted); }
.links-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.links-row a { color: var(--primary); }

@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; }
  .metrics-grid { grid-template-columns: 1fr; }
}
