:root {
  --wa: #25d366;
  --teal: #128c7e;
  --dark: #075e54;
  --bg: #f0f2f5;
  --card: #fff;
  --text: #111b21;
  --muted: #667781;
  --border: #e9edef;
  --danger: #dc3545;
  --online: #00a884;
  --shadow: 0 1px 3px rgba(0,0,0,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

/* ── Top Bar ─────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: var(--teal);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.topbar-logo { font-size: 1.1rem; font-weight: 700; letter-spacing: .3px; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  background: rgba(255,255,255,.15);
  border: none; border-radius: 50%;
  width: 36px; height: 36px;
  color: #fff; font-size: 1.1rem;
  cursor: pointer; display: grid; place-items: center;
}
.icon-btn:active { background: rgba(255,255,255,.3); }

/* ── Layout ──────────────────────────────────────────── */
.wrap { max-width: 680px; margin: 0 auto; padding: 12px 12px 24px; }

/* ── Card ────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title { font-weight: 700; font-size: 1rem; margin-bottom: 14px; color: var(--teal); }

/* ── Form Fields ─────────────────────────────────────── */
.field-group { margin-bottom: 10px; }
label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .95rem;
  color: var(--text); background: #fff;
  outline: none;
  -webkit-appearance: none;
}
input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(18,140,126,.12); }

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary {
  background: var(--teal); color: #fff;
  border: none; border-radius: 8px;
  padding: 11px 18px; font-size: .95rem; font-weight: 700;
  cursor: pointer; -webkit-appearance: none;
}
.btn-primary:active { opacity: .85; }
.full-btn { width: 100%; margin-top: 6px; }

.ghost-btn {
  background: none; border: 1.5px solid var(--border);
  border-radius: 8px; padding: 6px 12px;
  font-size: .82rem; color: var(--muted); cursor: pointer;
}
.ghost-btn:active { background: var(--bg); }

.action-btn {
  border: none; border-radius: 6px;
  padding: 6px 10px; font-size: .8rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.action-btn.start   { background: #e7f8f1; color: #00704a; }
.action-btn.restart { background: #fff4e0; color: #b35e00; }
.action-btn.stop    { background: #f8f8f8; color: var(--muted); }
.action-btn.log-btn { background: #eff3ff; color: #2962ff; }
.action-btn.del     { background: #ffeaea; color: var(--danger); }
.action-btn:active  { opacity: .75; }

/* ── Section label ───────────────────────────────────── */
.section-label {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted);
  padding: 0 4px 8px;
}

/* ── Account Cards ───────────────────────────────────── */
#accounts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.acc-card {
  background: var(--card);
  border-radius: 12px; padding: 14px 14px 12px;
  box-shadow: var(--shadow);
}
.acc-row1 { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.acc-name { font-weight: 700; font-size: 1rem; }
.acc-phone { font-size: .82rem; color: var(--muted); margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  font-size: .76rem; font-weight: 700;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.online  { background: #e7f8f1; color: var(--online); }
.badge.stopped { background: #ffeaea; color: var(--danger); }
.badge.unknown { background: #f0f0f0; color: var(--muted); }

.acc-meta { font-size: .78rem; color: var(--muted); margin-bottom: 10px; }

.acc-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Empty / Notice ──────────────────────────────────── */
.empty-state {
  text-align: center; padding: 28px 16px;
  color: var(--muted); font-size: .9rem;
  background: var(--card); border-radius: 12px;
  box-shadow: var(--shadow);
}

.notice {
  margin-top: 10px; padding: 10px 12px;
  border-radius: 8px; font-size: .85rem;
  background: #e7f8f1; color: #00704a;
  white-space: pre-wrap;
}
.notice.err { background: #ffeaea; color: var(--danger); }
.hidden { display: none !important; }

/* ── Log Box ─────────────────────────────────────────── */
.log-wrap { margin-bottom: 12px; }
.log-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.log-title { font-weight: 700; font-size: .95rem; color: var(--teal); }

.logbox {
  background: #1a1a2e; color: #a8ffce;
  border-radius: 8px; padding: 12px;
  font-size: .78rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  min-height: 160px; max-height: 42vh; overflow-y: auto;
  font-family: "JetBrains Mono", "Fira Code", monospace, sans-serif;
}

/* ── Footer ──────────────────────────────────────────── */
.footer { text-align: center; font-size: .75rem; color: var(--muted); padding: 8px 0 4px; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 400px) {
  .acc-actions { gap: 5px; }
  .action-btn { padding: 5px 8px; font-size: .76rem; }
  .logbox { font-size: .74rem; }
}
