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

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --border: #334155;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Login */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  margin: 0 auto 16px;
}

.logo-icon.small {
  width: 36px;
  height: 36px;
  font-size: 14px;
  margin: 0;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.9;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-warning {
  background: var(--warning);
  color: #000;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-full {
  width: 100%;
}

.error-message {
  margin-top: 12px;
  padding: 10px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.875rem;
  display: none;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 1.125rem;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.875rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.online {
  background: var(--success);
}

.status-dot.offline {
  background: var(--danger);
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

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

.card.full-width {
  grid-column: 1 / -1;
}

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}

.info-row:last-child {
  border-bottom: none;
  margin-bottom: 16px;
}

/* Table */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

th, td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.actions {
  display: flex;
  gap: 8px;
}

.actions .btn {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

/* Code / Config */
code, .config-box {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.8125rem;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text);
}

.config-box {
  padding: 16px;
  white-space: pre-wrap;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 16px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.qr-container {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.qr-container img {
  border-radius: var(--radius);
  background: white;
  padding: 8px;
}

/* Peer Status */
.peer-status {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.peer-status.online {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.peer-status.offline {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* Hint */
.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Logs */
.log-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.log-count {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.logs-container {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--bg);
}

.log-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  font-size: 0.875rem;
}

.log-entry {
  padding: 10px 14px;
  margin-bottom: 6px;
  border-radius: var(--radius);
  border-left: 3px solid var(--text-muted);
  background: var(--surface);
}

.log-entry:last-child {
  margin-bottom: 0;
}

.log-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
  font-size: 0.75rem;
}

.log-type {
  font-weight: 600;
  color: var(--text-muted);
}

.log-time {
  color: var(--text-muted);
}

.log-message {
  font-size: 0.875rem;
  color: var(--text);
}

.log-connection {
  border-left-color: var(--success);
}

.log-error {
  border-left-color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

.log-stats {
  border-left-color: var(--primary);
}

.log-info {
  border-left-color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  .cards {
    grid-template-columns: 1fr;
  }
  .navbar {
    padding: 12px 16px;
  }
  .container {
    padding: 16px;
  }
  .actions {
    flex-wrap: wrap;
  }
}
