:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.screen {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.login-card {
  width: 100%;
  max-width: 400px;
  margin: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.5rem;
  color: white;
}

.logo.small {
  width: 48px;
  height: 48px;
  font-size: 1.1rem;
  margin: 0;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

label {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
  color: inherit;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.stats-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

.stats-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.stats-values {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
}

.stat-num {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.stat-num.stat-active {
  color: var(--success);
}

.stat-sep {
  font-size: 1.25rem;
  color: var(--text-muted);
  font-weight: 300;
}

.stats-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

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

.nav-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--text);
}

.nav-icon {
  width: 1.5rem;
  text-align: center;
  font-size: 1.1rem;
  opacity: 0.9;
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.btn-block {
  width: 100%;
}

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

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.content-header h1 {
  font-size: 1.35rem;
  margin: 0;
}

.content-main {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.view-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: -0.5rem 0 1rem;
}

.badge {
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.create-form {
  display: flex;
  gap: 0.75rem;
}

.create-form input {
  flex: 1;
  margin-bottom: 0;
}

.create-form .btn-primary {
  width: auto;
  white-space: nowrap;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2 {
  margin-bottom: 0;
}

.clients-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.client-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  gap: 1rem;
}

.client-item.online {
  border-color: rgba(34, 197, 94, 0.35);
}

.client-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
  background: var(--text-muted);
}

.client-item.online .client-status-dot {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.client-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.status-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

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

.status-badge.offline {
  background: rgba(139, 156, 179, 0.15);
  color: var(--text-muted);
}

.client-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
  line-height: 1.5;
}

.client-info strong {
  display: block;
  font-size: 1rem;
}


.client-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.config-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.8rem;
  font-family: ui-monospace, monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.modal-actions .btn-primary {
  width: auto;
  flex: 1;
  min-width: 120px;
}

#modal-config {
  user-select: all;
  cursor: text;
}

.qr-image {
  display: block;
  margin: 1rem auto 0;
  max-width: 220px;
  border-radius: 8px;
}

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .nav-btn {
    flex: 1;
    min-width: 140px;
    justify-content: center;
  }

  .content-main {
    padding: 1rem;
  }

  .create-form {
    flex-direction: column;
  }

  .create-form .btn-primary {
    width: 100%;
  }

  .client-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .client-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}
