/* ============================================
   PAINEL DE PROSPECÇÃO WHATSAPP
   Premium Dark Theme (Instâncias Ilimitadas & QR Code)
   ============================================ */

/* --- VARIABLES --- */
:root {
  --bg-base: #06060f;
  --bg-surface: #0c0c1d;
  --bg-card: rgba(14, 14, 32, 0.75);
  --bg-card-hover: rgba(18, 18, 40, 0.85);
  --bg-input: rgba(8, 8, 22, 0.9);
  --bg-input-focus: rgba(12, 12, 30, 0.95);

  --text-primary: #eef2ff;
  --text-secondary: #a1a1c7;
  --text-muted: #6b6b8d;
  --text-code: #c4b5fd;

  --purple: #8b5cf6;
  --purple-dim: rgba(139, 92, 246, 0.15);
  --purple-glow: rgba(139, 92, 246, 0.25);
  --blue: #3b82f6;
  --cyan: #06b6d4;
  --emerald: #10b981;
  --emerald-dim: rgba(16, 185, 129, 0.15);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.15);
  --rose: #f43f5e;
  --rose-dim: rgba(244, 63, 94, 0.15);
  --white-5: rgba(255,255,255,0.05);
  --white-8: rgba(255,255,255,0.08);
  --white-12: rgba(255,255,255,0.12);

  --gradient: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 50%, #06b6d4 100%);
  --gradient-btn: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  --gradient-btn-hover: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);

  --border: rgba(139, 92, 246, 0.12);
  --border-hover: rgba(139, 92, 246, 0.3);
  --border-focus: rgba(139, 92, 246, 0.5);

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.12);
  --shadow-glow-hover: 0 0 50px rgba(139, 92, 246, 0.2);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --transition: all 0.3s var(--ease);
}

/* --- RESET --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* --- BACKGROUND --- */
.bg-gradient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(139,92,246,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(6,182,212,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(59,130,246,0.04) 0%, transparent 60%);
}

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.03;
  background-image:
    linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* --- APP LAYOUT --- */
#app {
  position: relative; z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

/* --- HEADER --- */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

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

.logo-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--purple-dim);
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 20px rgba(139,92,246,0.15);
}

.header-title {
  font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; letter-spacing: 0.03em; }

.header-right { display: flex; align-items: center; gap: 12px; }

.status-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.78rem; font-weight: 500; color: var(--text-secondary);
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
.status-dot.offline { background: var(--rose); box-shadow: 0 0 8px var(--rose); }

/* --- MAIN --- */
.main { display: flex; flex-direction: column; gap: 24px; }

/* --- CARDS --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-glow); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; flex-wrap: wrap; gap: 12px;
}
.card-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-title { display: flex; align-items: center; gap: 10px; }
.card-title h2 { font-size: 1.08rem; font-weight: 600; letter-spacing: -0.01em; }
.card-icon { font-size: 1.2rem; }

.card-description { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }
.card-description code {
  background: var(--purple-dim); color: var(--text-code);
  padding: 2px 7px; border-radius: 4px; font-size: 0.8rem; font-weight: 500;
}

.badge {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--purple-dim);
  color: var(--purple);
  border: 1px solid rgba(139,92,246,0.2);
  display: inline-flex; align-items: center; gap: 6px;
}
.badge-count { background: rgba(6,182,212,0.12); color: var(--cyan); border-color: rgba(6,182,212,0.2); }
.badge-success { background: var(--emerald-dim); color: var(--emerald); border-color: rgba(16,185,129,0.25); }

/* --- INSTANCES (DYNAMIC & UNLIMITED) --- */
.instances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.instance-card {
  background: var(--white-5);
  border: 1px solid var(--white-8);
  border-radius: var(--radius-sm);
  padding: 16px;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.instance-card:hover { border-color: var(--border-hover); background: var(--white-8); }
.instance-card.active-selected {
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.1);
}

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

.instance-status-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.72rem; font-weight: 600;
  padding: 3px 8px; border-radius: 100px;
}
.instance-status-tag.open {
  background: var(--emerald-dim); color: var(--emerald); border: 1px solid rgba(16,185,129,0.3);
}
.instance-status-tag.close, .instance-status-tag.disconnected {
  background: var(--rose-dim); color: var(--rose); border: 1px solid rgba(244,63,94,0.3);
}
.instance-status-tag.connecting {
  background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,158,11,0.3);
}

.instance-body {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}

.instance-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--purple-dim);
  border: 2px solid var(--white-12);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; color: var(--text-primary);
  overflow: hidden; flex-shrink: 0;
}
.instance-avatar img { width: 100%; height: 100%; object-fit: cover; }

.instance-info { flex: 1; min-width: 0; }
.instance-name {
  font-size: 0.92rem; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
.instance-phone {
  font-size: 0.78rem; color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace; margin-top: 2px;
}
.instance-profile { font-size: 0.72rem; color: var(--text-muted); }

.instance-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--white-8);
}

.instance-toggle-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.76rem; color: var(--text-secondary);
  cursor: pointer; user-select: none;
}
.instance-toggle-label input[type="checkbox"] {
  accent-color: var(--purple); width: 15px; height: 15px; cursor: pointer;
}

.instance-actions-btns { display: flex; align-items: center; gap: 6px; }

.btn-icon-danger {
  background: transparent; border: none; color: var(--text-muted);
  padding: 6px; border-radius: var(--radius-xs); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.btn-icon-danger:hover { color: var(--rose); background: var(--rose-dim); }

.instances-footer {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--white-5);
  border: 1px solid var(--white-8);
  border-radius: var(--radius-sm);
  font-size: 0.8rem; color: var(--text-secondary);
}
.instances-summary { flex: 1; font-weight: 500; }
.dot-sep { color: var(--text-muted); }

.empty-instances {
  text-align: center; padding: 40px 20px;
  background: var(--white-5); border: 1px dashed var(--white-12);
  border-radius: var(--radius-sm); grid-column: 1 / -1;
}
.empty-instances p { color: var(--text-muted); margin-bottom: 12px; font-size: 0.86rem; }

/* --- INPUTS --- */
.input, .textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--white-8);
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  transition: var(--transition);
  outline: none;
}
.input:focus, .textarea:focus {
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.1);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); font-size: 0.82rem; }
.textarea { resize: vertical; min-height: 60px; line-height: 1.5; }

/* --- BUTTONS --- */
.btn-sm {
  padding: 7px 14px;
  font-size: 0.78rem; font-weight: 500;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-family: 'Inter', sans-serif;
  display: inline-flex; align-items: center; gap: 6px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--purple-dim); border-color: var(--border-hover); color: var(--text-primary); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.78rem; font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.btn-ghost:hover { background: var(--purple-dim); border-color: var(--border-hover); color: var(--text-primary); }

.btn-accent {
  background: var(--purple-dim);
  border: 1px solid rgba(139,92,246,0.3);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 0.82rem; font-weight: 600;
  transition: var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-accent:hover {
  background: rgba(139,92,246,0.3);
  border-color: var(--purple);
  box-shadow: 0 0 16px rgba(139,92,246,0.2);
}

.btn-primary {
  background: var(--gradient-btn);
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(124,58,237,0.35);
  letter-spacing: 0.02em;
  padding: 10px 20px;
  border-radius: var(--radius-xs);
}
.btn-primary:hover {
  background: var(--gradient-btn-hover);
  box-shadow: 0 6px 28px rgba(139,92,246,0.45);
  transform: translateY(-1px);
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--white-8);
  border: 1px solid var(--white-12);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-xs);
  font-size: 0.82rem; font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.btn-secondary:hover { background: var(--white-12); color: var(--text-primary); }

.btn-text {
  background: transparent; border: none;
  color: var(--text-muted); font-size: 0.75rem;
  cursor: pointer; padding: 2px 6px; border-radius: 4px;
  transition: var(--transition);
}
.btn-text:hover { color: var(--text-primary); background: var(--white-5); }

.btn-launch { width: 100%; padding: 16px; font-size: 1rem; border-radius: var(--radius); }

.btn-primary.running {
  background: linear-gradient(135deg, var(--rose), #dc2626);
  box-shadow: 0 4px 24px rgba(244,63,94,0.3);
}
.btn-primary.running:hover { box-shadow: 0 6px 32px rgba(244,63,94,0.5); }

/* --- MESSAGES --- */
.messages-list { display: flex; flex-direction: column; gap: 12px; }

.msg-item {
  display: flex; gap: 14px;
  padding: 14px;
  background: var(--white-5);
  border: 1px solid var(--white-8);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.msg-item:hover { border-color: var(--border-hover); background: var(--white-8); }

.msg-badge {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--purple-dim);
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: 50%;
  font-size: 0.75rem; font-weight: 700; color: var(--purple);
  flex-shrink: 0;
}

.msg-content { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.msg-footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.72rem; }
.msg-preview { color: var(--text-muted); }
.msg-preview strong { color: var(--text-secondary); }
.msg-charcount { color: var(--text-muted); font-family: monospace; }

/* --- GRID 2 COLUNAS --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* --- TIMING --- */
.timing-controls { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.range-group { display: flex; flex-direction: column; gap: 6px; }
.range-label { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-secondary); }
.range-val { font-weight: 700; color: var(--text-primary); font-family: monospace; }

.range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px;
  background: var(--white-8);
  border-radius: 100px;
  outline: none;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px;
  background: var(--purple);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(139,92,246,0.5);
  transition: var(--transition);
}
.range::-webkit-slider-thumb:hover { transform: scale(1.15); box-shadow: 0 0 16px rgba(139,92,246,0.8); }

.timing-summary {
  background: var(--white-5);
  border: 1px solid var(--white-8);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.timing-visual { margin-bottom: 12px; }
.timing-bar { position: relative; height: 10px; background: var(--white-8); border-radius: 100px; }
.timing-bar-fill {
  position: absolute; top: 0; height: 100%;
  background: var(--gradient); border-radius: 100px;
  transition: left 0.2s, width 0.2s;
}
.timing-marker {
  position: absolute; top: 14px; transform: translateX(-50%);
  font-size: 0.68rem; font-family: monospace; color: var(--text-muted);
}
.timing-text { font-size: 0.8rem; color: var(--text-secondary); text-align: center; }
.timing-text strong { color: var(--purple); }

/* --- CONTATOS --- */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; background: var(--white-5); padding: 4px; border-radius: var(--radius-xs); }
.tab {
  flex: 1; padding: 7px;
  background: transparent; border: none;
  color: var(--text-muted); font-size: 0.78rem; font-weight: 500;
  border-radius: var(--radius-xs); cursor: pointer; transition: var(--transition);
}
.tab.active { background: var(--purple-dim); color: var(--text-primary); font-weight: 600; }

.tab-panel { display: flex; flex-direction: column; gap: 10px; }

.drop-zone {
  border: 2px dashed var(--white-12);
  border-radius: var(--radius-sm);
  padding: 28px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: var(--transition);
  color: var(--text-muted); font-size: 0.82rem;
}
.drop-zone.dragover { border-color: var(--purple); background: var(--purple-dim); }
.drop-or { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; }
.upload-label { cursor: pointer; }

.contacts-preview {
  margin-top: 14px; max-height: 150px; overflow-y: auto;
  border: 1px solid var(--white-8); border-radius: var(--radius-xs);
  padding: 8px 12px; background: var(--white-5); font-size: 0.76rem;
}
.empty-state { color: var(--text-muted); text-align: center; padding: 16px 0; }
.contact-row {
  display: flex; justify-content: space-between; padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03); color: var(--text-secondary);
}
.contact-row:last-child { border-bottom: none; }
.contact-row span:last-child { font-family: monospace; color: var(--text-muted); }

/* --- CONTROLE --- */
.card-control { border-color: rgba(139,92,246,0.25); }
.control-buttons { margin-bottom: 20px; }

.progress-section { margin-bottom: 20px; }
.progress-info { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.82rem; color: var(--text-secondary); }
.progress-info span:last-child { font-weight: 700; color: var(--text-primary); }

.progress-track {
  width: 100%; height: 8px;
  background: var(--white-8); border-radius: 100px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: var(--gradient); border-radius: 100px;
  transition: width 0.6s var(--ease);
  box-shadow: 0 0 12px rgba(139,92,246,0.4);
}
.progress-eta { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; text-align: right; }

/* --- LOG --- */
.log-section {
  background: #050510;
  border: 1px solid var(--white-8);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.log-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: var(--white-5); border-bottom: 1px solid var(--white-8);
  font-size: 0.78rem; font-weight: 600; color: var(--text-secondary);
}
.log-body {
  padding: 12px 16px;
  max-height: 200px; overflow-y: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.74rem; line-height: 1.7;
}
.log-entry { padding: 2px 0; color: var(--text-muted); }
.log-entry.log-success { color: var(--emerald); }
.log-entry.log-error { color: var(--rose); }
.log-entry.log-info { color: var(--text-secondary); }
.log-entry.log-warn { color: var(--amber); }
.log-entry .log-time { color: var(--text-muted); margin-right: 8px; }

/* --- TOAST --- */
.toast-wrap {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  font-size: 0.82rem;
  animation: slideIn 0.3s var(--ease), fadeOut 0.3s var(--ease) 2.7s forwards;
  max-width: 380px;
}
.toast.toast-success { border-left: 3px solid var(--emerald); }
.toast.toast-error { border-left: 3px solid var(--rose); }
.toast.toast-info { border-left: 3px solid var(--blue); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(30px); } }

/* --- MODAL --- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(4, 4, 12, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
  overflow-y: auto;
  animation: fadeIn 0.25s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: #0d0d22;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 14px;
  max-width: 440px; width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7), 0 0 40px rgba(139, 92, 246, 0.15);
  overflow: hidden;
  animation: modalScale 0.3s var(--ease);
}
@keyframes modalScale { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--white-8);
  flex-shrink: 0;
}
.modal-title-wrap { display: flex; align-items: center; gap: 10px; }
.modal-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-xs);
  background: var(--purple-dim);
  color: var(--purple);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.modal-title { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); }
.modal-subtitle { font-size: 0.72rem; color: var(--text-muted); }
.modal-close {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 1.35rem; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--text-primary); background: var(--white-8); }

.modal-body {
  padding: 14px 18px;
  overflow-y: auto;
  flex: 1;
}
.modal-step { display: flex; flex-direction: column; gap: 12px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); }
.input-with-button { display: flex; gap: 8px; }
.input-with-button .input { flex: 1; }
.field-hint { font-size: 0.7rem; color: var(--text-muted); }

.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* --- QR CODE BOX --- */
.qr-container {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 4px 0;
}

.qr-box {
  width: 190px; height: 190px;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
.qr-image {
  width: 100%; height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.qr-expired-overlay {
  position: absolute; inset: 0;
  background: rgba(10, 10, 20, 0.92);
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; text-align: center; color: var(--rose); font-weight: 600; font-size: 0.85rem;
}

.qr-status-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.78rem; color: var(--text-secondary);
}
.status-pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 0.4; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.qr-timer-bar {
  width: 190px; height: 3px;
  background: var(--white-8); border-radius: 100px; overflow: hidden;
}
.qr-timer-fill {
  height: 100%; width: 100%;
  background: var(--cyan);
  transition: width 1s linear;
}

.pairing-code-wrap {
  text-align: center; margin-top: 2px;
}
.pairing-label { font-size: 0.7rem; color: var(--text-muted); display: block; margin-bottom: 2px; }
.pairing-code {
  font-family: 'JetBrains Mono', monospace; font-size: 1.05rem; font-weight: 700;
  letter-spacing: 0.12em; color: var(--purple);
  padding: 4px 12px; background: var(--purple-dim);
  border: 1px dashed rgba(139, 92, 246, 0.4); border-radius: var(--radius-xs);
  display: inline-block;
}

.instructions-card {
  background: var(--white-5);
  border: 1px solid var(--white-8);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.74rem;
}
.instructions-card h4, .instructions-title {
  font-size: 0.78rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px;
}
.instructions-card ol { padding-left: 16px; color: var(--text-secondary); line-height: 1.5; margin: 0; }
.instructions-card li strong { color: var(--text-primary); }
.instructions-steps {
  display: flex; flex-direction: column; gap: 3px; color: var(--text-secondary); line-height: 1.4;
}
.instructions-steps strong { color: var(--text-primary); }

/* --- SUCCESS BOX --- */
.success-box {
  text-align: center; padding: 24px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.success-icon-wrap {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--emerald-dim); border: 2px solid rgba(16, 185, 129, 0.4);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.2);
  animation: bounceIn 0.5s var(--ease);
}
@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
.success-box h3 { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); }
.success-box p { font-size: 0.82rem; color: var(--text-muted); }

/* --- SPINNER --- */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--white-12);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 36px; grid-column: 1 / -1; color: var(--text-muted); font-size: 0.85rem;
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--white-12); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--white-8); }

/* --- HIDDEN --- */
.hidden { display: none !important; }

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .instances-grid { grid-template-columns: 1fr; }
  #app { padding: 0 16px 40px; }
  .header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-right { width: 100%; justify-content: flex-end; }
  .card-header { flex-direction: column; align-items: flex-start; }
  .card-header-actions { width: 100%; justify-content: flex-start; }
}
