:root {
  --bg: #080b10;
  --surface: #0f141c;
  --surface-2: #151c28;
  --border: rgba(255, 255, 255, 0.06);
  --text: #e8edf5;
  --muted: #7b8798;
  --accent: #3dd6c3;
  --accent-dim: rgba(61, 214, 195, 0.12);
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  font-family: 'DM Sans', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  z-index: 0;
}

.bg-glow--a {
  width: 420px;
  height: 420px;
  top: -120px;
  right: -80px;
  background: rgba(61, 214, 195, 0.08);
}

.bg-glow--b {
  width: 360px;
  height: 360px;
  bottom: -100px;
  left: -60px;
  background: rgba(99, 102, 241, 0.06);
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border);
  background: rgba(15, 20, 28, 0.6);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem 0.75rem 1.5rem;
}

.brand__mark {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.brand__sub {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, color 0.2s;
}

.nav__item:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.nav__item--active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav__item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav__icon {
  font-size: 0.75rem;
  opacity: 0.8;
}

.sidebar__footer {
  padding: 1rem 0.75rem 0;
  border-top: 1px solid var(--border);
}

.sidebar__footer p {
  margin: 0.25rem 0;
  font-size: 0.75rem;
}

.main {
  padding: 2rem 2.5rem;
  max-width: 1100px;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.muted.small {
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--muted);
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  padding: 0.15em 0.4em;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--accent);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s, box-shadow 0.3s;
}

.status-pill[data-status='connected'] .status-pill__dot {
  background: var(--success);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.6);
}

.status-pill[data-status='qr'] .status-pill__dot,
.status-pill[data-status='connecting'] .status-pill__dot,
.status-pill[data-status='reconnecting'] .status-pill__dot {
  background: var(--warning);
  animation: pulse 1.4s ease-in-out infinite;
}

.status-pill[data-status='logged_out'] .status-pill__dot {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card--primary {
  grid-row: span 2;
}

.card--wide {
  grid-column: 1 / -1;
}

.card__title {
  margin: 0;
  padding: 1rem 1.25rem 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.card__body {
  padding: 1.25rem 1.5rem 1.5rem;
}

.hidden {
  display: none !important;
}

.qr-panel {
  text-align: center;
}

.qr-panel__title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.qr-panel__hint {
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

.qr-frame {
  display: inline-flex;
  padding: 1rem;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.qr-frame img {
  display: block;
  border-radius: 8px;
}

.connected-panel {
  text-align: center;
  padding: 1.5rem 0;
}

.connected-panel__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--success);
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.25);
  border-radius: 50%;
}

.connected-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.phone {
  margin: 1rem 0 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  color: var(--accent);
}

.waiting-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 280px;
  color: var(--muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-panel {
  padding: 1rem;
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--danger);
  font-size: 0.9rem;
}

.command-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 0.5rem;
}

.command-preview .arrow {
  color: var(--muted);
  font-size: 1.1rem;
}

.command-preview .response {
  color: var(--success);
  background: rgba(74, 222, 128, 0.08);
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
}

.log li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.log li:last-child {
  border-bottom: none;
}

.log .time {
  color: var(--accent);
  margin-right: 0.5rem;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar__footer {
    width: 100%;
  }

  .main {
    padding: 1.25rem;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .card--primary {
    grid-row: auto;
  }
}
