:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-alt: #f8f9fb;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e8eaee;
  --line-2: #d7dbe3;
  --primary-soft: #eef0f4;
  --success: #2e7d5b;
  --success-soft: #e7f1eb;
  --warn: #b5821b;
  --warn-soft: #f7f0e0;
  --danger: #c53b3b;
  --danger-soft: #fbeaea;
  --whatsapp: #25d366;
  --radius: 12px;
  --radius-sm: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.logo { display: block; height: auto; }

button:not(:disabled), a[href], label[for] { cursor: pointer; }
button:disabled { cursor: not-allowed; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:focus-visible, .input:focus-visible, .field input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--ink) 35%, transparent);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #000; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-alt); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--line); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }

.input, .field input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.input::placeholder { color: var(--faint); }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card .logo { margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 44px; }
.reveal {
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  font-size: 18px;
}
.reveal:hover { color: var(--ink); }
.reveal:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--ink) 35%, transparent);
  outline-offset: 2px;
}

.error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px dashed var(--line-2);
}
.brand { display: flex; align-items: center; gap: 12px; }
.divider { width: 1px; height: 20px; background: var(--line-2); }
.brand-title { font-weight: 600; font-size: 14px; }

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head > div { display: flex; flex-direction: column; gap: 2px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--primary-soft);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--success-soft); color: var(--success); }
.pill.wait { background: var(--warn-soft); color: var(--warn); }
.pill.off { background: var(--danger-soft); color: var(--danger); }

.qr-layout { display: flex; gap: 20px; align-items: center; }
.qr-frame {
  flex: none;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.qr-frame img { display: block; width: 200px; height: 200px; }
.steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; color: var(--ink-2); font-size: 13px; }

.account { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--whatsapp); color: #fff; font-weight: 600;
}
.account-name { font-weight: 600; }
.push { margin-left: auto; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--ink-2);
  font-size: 13px;
}
.empty-line { padding: 4px 0; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  min-width: 0;
}
.list > li:first-child { border-top: 0; }
.item-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.item-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
}

.picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}
.selectable { max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.selectable > li { padding: 8px 12px; }
.selectable label { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; }
.selectable input { width: 16px; height: 16px; accent-color: var(--ink); flex: none; }
.add-number { display: flex; gap: 8px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

.url {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.webhook-row { flex-wrap: wrap; }
.webhook-label { width: 200px; flex: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  max-width: calc(100% - 32px);
}
.toast.bad { background: var(--danger); }

@media (max-width: 820px) {
  .page { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .topbar { padding: 0 16px; }
  .brand-title, .divider { display: none; }
  .qr-layout { flex-direction: column; align-items: flex-start; }
  .webhook-label { width: 100%; }
  .btn { min-height: 40px; }
}
