:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --sidebar: #0f172a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px; color: #fff;
  padding: 0 20px 24px;
}
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--green);
}
.menu { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; flex: 1; }
.menu-item {
  text-align: left; background: none; border: none; color: #cbd5e1;
  padding: 11px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
  transition: all .15s;
}
.menu-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu-item.active { background: var(--green); color: #fff; font-weight: 600; }
.sidebar-status {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px; font-size: 12px; border-top: 1px solid rgba(255,255,255,.08);
}

/* Content */
.content { flex: 1; padding: 28px 32px; max-width: 1100px; }
.tab { display: none; }
.tab.active { display: block; }
h1 { font-size: 22px; margin-bottom: 18px; }
h3 { margin-bottom: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
}

/* Forms */
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-col { display: flex; flex-direction: column; gap: 16px; max-width: 520px; }
.form-col label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.form-col label.check-row { flex-direction: row; align-items: center; gap: 10px; }
.check-row input[type="checkbox"] { flex: 0 0 auto; min-width: 0; width: 18px; height: 18px; }
input, select, textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; flex: 1; min-width: 160px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); border-color: var(--green); }

/* Buttons */
.btn {
  padding: 10px 18px; border: 1px solid var(--border); background: #fff;
  border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Table */
.table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.table th, .table td {
  text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.table th { color: var(--muted); font-weight: 600; }
.table tbody tr:hover { background: #f8fafc; }

/* Connection */
.connection-card { display: flex; gap: 32px; flex-wrap: wrap; align-items: center; }
.conn-info { flex: 1; min-width: 260px; }
.status-line { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.steps { margin: 16px 0; padding-left: 18px; color: var(--muted); line-height: 1.9; }
.qr-box {
  width: 280px; height: 280px; display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--border); border-radius: 12px; background: #fff;
}
.qr-box img { width: 260px; height: 260px; }
.qr-placeholder { color: var(--muted); }

/* Status dot */
.status-dot { width: 11px; height: 11px; border-radius: 50%; background: #94a3b8; flex-shrink: 0; }
.status-dot.connected { background: var(--green); box-shadow: 0 0 0 4px rgba(22,163,74,.18); }
.status-dot.qr { background: #f59e0b; }
.status-dot.connecting { background: #f59e0b; }
.status-dot.logged_out { background: var(--danger); }

.muted { color: var(--muted); font-size: 13px; font-weight: 400; }

/* Badges */
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.active { background: #dcfce7; color: var(--green-dark); }
.badge.cancelled { background: #fee2e2; color: var(--danger); }
.badge.done { background: #e2e8f0; color: var(--muted); }
.badge.sent { background: #dcfce7; color: var(--green-dark); }
.badge.failed { background: #fee2e2; color: var(--danger); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--text); color: #fff;
  padding: 14px 20px; border-radius: 10px; opacity: 0; transform: translateY(10px);
  transition: all .25s; pointer-events: none; max-width: 320px; z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
