:root {
  --primary: #128c7e;
  --primary-hover: #075e54;
  --primary-light: #e8f5f1;
  --accent: #25d366;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --bg: #0f172a;
  --card-bg: #1e293b;
  --card-border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* NAVBAR */
.navbar {
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-container {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-circle-sm {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(37, 211, 102, 0.15);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(37, 211, 102, 0.3);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.status-pill .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-connected {
  background: rgba(37, 211, 102, 0.15);
  color: var(--accent);
  border: 1px solid rgba(37, 211, 102, 0.4);
}
.status-connected .status-dot {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.status-qr_ready {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.status-qr_ready .status-dot {
  background: var(--warning);
}

.status-connecting {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info);
  border: 1px solid rgba(59, 130, 246, 0.4);
}
.status-connecting .status-dot {
  background: var(--info);
  animation: pulse 1.5s infinite;
}

.status-disconnected, .status-logged_out {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.status-disconnected .status-dot, .status-logged_out .status-dot {
  background: var(--danger);
}

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

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}
.nav-link:hover {
  color: var(--text-main);
}

/* LAYOUT */
.dashboard-container {
  max-width: 1300px;
  width: 100%;
  margin: 24px auto;
  padding: 0 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.grid-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
}

@media (max-width: 960px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }
}

.side-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.grid-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 860px) {
  .grid-bottom {
    grid-template-columns: 1fr;
  }
}

/* CARDS */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-header.space-between {
  justify-content: space-between;
}

.header-with-icon {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(18, 140, 126, 0.15);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-webhook {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info);
}

.icon-key {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.icon-security {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.nav-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
}

.action-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.card-header h2, .card-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body {
  padding: 24px;
}

/* STATUS PANELS */
.status-panel {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* CONNECTED VIEW */
.success-banner {
  background: linear-gradient(135deg, rgba(18, 140, 126, 0.2), rgba(37, 211, 102, 0.05));
  border: 1px solid rgba(37, 211, 102, 0.3);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(37, 211, 102, 0.2);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tag-live {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.success-meta h3 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 4px 0 2px 0;
  letter-spacing: -0.01em;
}

.action-buttons-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* QR VIEW */
.qr-container {
  display: flex;
  gap: 28px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.qr-box {
  width: 220px;
  height: 220px;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  border-radius: var(--radius-md);
  gap: 12px;
}

.qr-instructions h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.qr-instructions ol {
  padding-left: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 16px;
}

.qr-instructions strong {
  color: var(--text-main);
}

.qr-actions {
  display: flex;
  gap: 10px;
}

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 20px 10px;
}

.empty-icon {
  color: var(--text-muted);
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 440px;
  margin: 0 auto 20px auto;
}

.pairing-code-section {
  max-width: 440px;
  margin: 24px auto 0 auto;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.divider span {
  padding: 0 10px;
}

.pairing-form {
  display: flex;
  gap: 8px;
}

.pairing-code-display {
  margin-top: 14px;
  background: rgba(18, 140, 126, 0.15);
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.pairing-code-display span {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.code-box {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.2em;
}

/* WEBHOOK & API CARDS */
.form-group {
  margin-bottom: 16px;
}

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

.input-with-button {
  display: flex;
  gap: 8px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.9rem;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--primary);
}

.webhook-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.status-msg {
  font-size: 0.8rem;
  font-weight: 500;
}

.webhook-status-box {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.status-row .label {
  color: var(--text-muted);
}

.status-row .value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.token-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 16px;
}

.token-display code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-snippet {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.snippet-header {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-copy-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.72rem;
  cursor: pointer;
  font-weight: 600;
}

.api-snippet pre {
  padding: 10px 12px;
  overflow-x: auto;
}

.api-snippet code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #cbd5e1;
  line-height: 1.5;
}

/* ACTIVITY CONSOLE */
.console-box {
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 240px;
  overflow-y: auto;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  display: flex;
  flex-direction: column-reverse; /* latest on top */
  gap: 6px;
}

.log-entry {
  display: flex;
  gap: 8px;
  align-items: baseline;
  line-height: 1.4;
  word-break: break-all;
}

.log-time {
  color: var(--text-muted);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.log-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.tag-info { background: rgba(59, 130, 246, 0.2); color: var(--info); }
.tag-message { background: rgba(37, 211, 102, 0.2); color: var(--accent); }
.tag-error { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.tag-status { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

.log-text {
  color: #e2e8f0;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #334155;
  color: #fff;
}
.btn-secondary:hover {
  background: #475569;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-outline-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-outline-secondary:hover {
  color: var(--text-main);
  border-color: #64748b;
}

.btn-outline-danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}
.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.72rem;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

/* SPINNER */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* FOOTER */
.footer {
  border-top: 1px solid var(--border);
  padding: 16px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--primary);
  text-decoration: none;
}

/* LOGIN PAGE */
.login-body {
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

.login-wrapper {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.logo-circle {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px auto;
}

.login-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 16px;
}

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

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.login-footer code {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 5px;
  border-radius: 4px;
}

.text-danger { color: var(--danger); }
.text-xs { font-size: 0.72rem; color: var(--text-muted); }
.muted-text { color: var(--text-muted); font-size: 0.85rem; }

