:root {
  --bg: #f0f2f5;
  --card: #fff;
  --text: #1f2c34;
  --muted: #667781;
  --border: #e2e6ea;
  --green: #00a884;
  --green-dark: #008069;
  --red: #d9534f;
  --amber: #e0a100;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
header { background: var(--green-dark); color: #fff; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
header h1 { font-size: 20px; margin: 0; }
.badge { padding: 4px 12px; border-radius: 999px; font-size: 13px; background: rgba(255,255,255,.2); }
.badge.ready { background: #25d366; color: #073b26; }
.badge.qr, .badge.loading, .badge.starting, .badge.waiting { background: #ffd966; color: #4a3b00; }
.badge.error, .badge.stopped { background: #ffb3b0; color: #5a0f0c; }

main { display: flex; gap: 20px; padding: 20px; max-width: 1400px; margin: 0 auto; flex-wrap: wrap; }
.col { flex: 1 1 360px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.col.wide { flex: 2 1 560px; }
.card { background: var(--card); border-radius: 10px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card h2 { margin: 0 0 12px; font-size: 17px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 6px; }
select { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; }
textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; resize: vertical; }
code { background: #eef1f3; padding: 1px 5px; border-radius: 4px; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

button { font: inherit; border: 0; border-radius: 8px; padding: 9px 14px; cursor: pointer; background: var(--green); color: #fff; }
button:hover:not(:disabled) { background: var(--green-dark); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: #e9edef; color: var(--text); }
button.secondary:hover:not(:disabled) { background: #d5dbdf; }
button.danger { background: #fbe9e8; color: var(--red); }
button.danger:hover:not(:disabled) { background: #f6d2d0; }
button.small { padding: 5px 10px; font-size: 13px; }
button.link { background: none; color: var(--muted); padding: 6px; margin-left: auto; }
button.link:hover:not(:disabled) { background: none; text-decoration: underline; }
.danger-text { color: var(--red) !important; }
button.big { width: 100%; padding: 16px; font-size: 17px; font-weight: 600; }

#conn-body { text-align: center; }
#qr { width: 280px; max-width: 100%; border: 1px solid var(--border); border-radius: 8px; }
#image-box { border: 1px dashed var(--border); border-radius: 8px; padding: 10px; text-align: center; }
#image-preview { max-width: 100%; max-height: 220px; border-radius: 6px; }

.list-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.counts { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.pill.pending, .st.pending { background: #fff4d6; color: #7a5a00; }
.pill.sent, .st.sent { background: #d9fdd3; color: #0a5c36; }
.pill.failed, .st.failed { background: #fde2e1; color: #9b1c18; }
.next-box { margin: 14px 0; }
.next-box p { margin: 8px 0 0; text-align: center; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 8px; flex-wrap: wrap; }
.tabs button { background: none; color: var(--muted); padding: 6px 12px; }
.tabs button.active { background: #e7f8f3; color: var(--green-dark); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }
td.actions { text-align: right; }
td.actions button + button { margin-left: 6px; }
.st { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.err { display: block; color: var(--red); font-size: 12px; white-space: normal; max-width: 260px; }
tr.sending { background: #f3fbf8; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2c34; color: #fff; padding: 12px 18px; border-radius: 8px; max-width: 90vw; box-shadow: 0 4px 12px rgba(0,0,0,.2); z-index: 10; }
#toast.error { background: var(--red); }

@media (max-width: 600px) {
  main { padding: 12px; }
  header { padding: 12px 16px; }
}

.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.user { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.user img { width: 28px; height: 28px; border-radius: 50%; }
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { max-width: 400px; width: 100%; text-align: center; }
.login-card h1 { font-size: 22px; margin: 0 0 8px; color: var(--green-dark); }
.login-card #google-btn { display: flex; justify-content: center; margin: 4px 0 8px; min-height: 44px; }
.login-tabs { justify-content: center; margin: 16px 0 12px; }
.auth-form { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.auth-form input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.auth-form button[type=submit] { width: 100%; }
.auth-form h2 { margin: 0 0 4px; font-size: 17px; }
.divider { margin: 14px 0 8px; }
dialog { border: 0; border-radius: 10px; padding: 18px; width: min(380px, calc(100vw - 32px)); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog .row button { flex: 1; }
.login-card .err { max-width: none; margin-top: 10px; }
