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

:root {
  --bg:       #111213;
  --surface:  #1c1d1f;
  --surface2: #242628;
  --border:   #2e3033;
  --accent:   #00d4ff;
  --accent2:  #00aacc;
  --text:     #e8e9ea;
  --muted:    #6b7280;
  --danger:   #e05252;
  --success:  #34d399;
  --warning:  #f59e0b;
  --radius:   10px;
  --font:     'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono:     'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
}

/* ── LOGIN ─────────────────────────────────────── */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 36px;
  width: 340px;
}

.brand { margin-bottom: 24px; }
.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #fff;
}
.brand-name span { color: var(--accent); }
.brand-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  transition: opacity 0.15s, background 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #000; width: 100%; padding: 12px; border-radius: 8px; }
.btn-primary:hover:not(:disabled) { background: var(--accent2); }
.btn-ghost { background: transparent; color: #9ca3af; border: 1px solid #4b5563; }
.btn-ghost:hover { color: var(--text); border-color: #9ca3af; background: rgba(255,255,255,0.05); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid #3a2020; }
.btn-danger:hover { background: #2a1515; }
.btn-sm { font-size: 12px; padding: 6px 12px; }

.error-msg { color: var(--danger); font-size: 12px; margin-top: 10px; text-align: center; }

.var-chip {
  background: #1e3a5f; color: #60a5fa;
  border: 1px solid #2563eb44; border-radius: 5px;
  font-size: 11px; padding: 3px 9px; cursor: pointer;
  font-family: var(--mono); transition: background .15s;
}
.var-chip:hover { background: #2563eb; color: #fff; }

/* ── LAYOUT ─────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

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

.sidebar-brand { margin-bottom: 32px; padding: 0 8px; }
.sidebar-brand .brand-name { font-size: 18px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.12s, color 0.12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: #0d2f38; color: var(--accent); }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer { margin-top: auto; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }

.wa-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.wa-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.wa-badge.ready .wa-dot { background: var(--success); box-shadow: 0 0 6px var(--success); }
.wa-badge.qr .wa-dot { background: var(--warning); }
.wa-badge.connecting .wa-dot { background: var(--warning); animation: pulse 1s infinite; }

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

.content { flex: 1; overflow-y: auto; padding: 28px; }

/* ── CARDS ─────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text); }

/* ── STAT ROW ─────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-value.accent { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-value.danger  { color: var(--danger); }
.stat-value.warning { color: var(--warning); }

/* ── TABLE ─────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
td { padding: 10px 12px; border-bottom: 1px solid #1e2022; font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #16181a; }

/* ── BADGE STATUS ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: var(--mono);
  padding: 3px 8px;
  border-radius: 20px;
}
.badge-running { background: #0d2a20; color: var(--success); }
.badge-paused  { background: #2a2416; color: var(--warning); }
.badge-sent    { background: #0d2a20; color: var(--success); }
.badge-pending { background: #1a1c1f; color: var(--muted); }
.badge-error   { background: #2a1515; color: var(--danger); }

/* ── FORM ──────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-full { grid-column: 1 / -1; }
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 14px;
  outline: none;
  resize: vertical;
  min-height: 100px;
}
textarea:focus { border-color: var(--accent); }
input[type=number], input[type=text] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 9px 14px;
  outline: none;
}
input:focus { border-color: var(--accent); }

.hint { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 4px; }

/* ── QR ──────────────────────────────────────────── */
#qr-section { text-align: center; padding: 20px 0; }
#qr-section img { border-radius: 10px; border: 4px solid var(--surface2); max-width: 220px; }
#qr-section p { color: var(--muted); font-size: 12px; margin-top: 12px; }

/* ── MODAL ──────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 520px;
  max-width: 95vw;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ── PROGRESS BAR ────────────────────────────────── */
.progress-wrap { background: var(--surface2); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar  { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.4s; }

/* ── UPLOAD AREA ─────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}
.upload-area:hover, .upload-area.drag { border-color: var(--accent); }
.upload-area input { display: none; }

/* ── SCROLLBAR ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── UTILS ───────────────────────────────────────── */
.hidden { display: none !important; }
.flex    { display: flex; }
.gap-8   { gap: 8px; }
.gap-12  { gap: 12px; }
.ml-auto { margin-left: auto; }
.text-muted { color: var(--muted); }
.text-sm    { font-size: 12px; }
.mt-16  { margin-top: 16px; }
.mb-16  { margin-bottom: 16px; }
