:root {
  --green: #128c7e;
  --green-dark: #075e54;
  --bg: #f0f2f5;
  --card: #fff;
  --text: #1f2c34;
  --muted: #667781;
  --border: #e3e6e8;
  --danger: #d93025;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }

body { margin: 0; background: var(--bg); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--green-dark);
  color: #fff;
}
.topbar h1 { margin: 0; font-size: 1.2rem; }

main {
  width: min(100% - 32px, 900px);
  margin: 24px auto 48px;
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--card);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
}
.panel h2 { margin: 0 0 14px; font-size: 1.1rem; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.panel-head h2 { margin: 0; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row + .row, form + .row { margin-top: 14px; }

label { display: grid; gap: 4px; font-size: 0.9rem; font-weight: 500; margin-bottom: 10px; }
label.check { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.row label { flex: 1; min-width: 140px; }

input, textarea {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--green); border-color: transparent; }
textarea { width: 100%; resize: vertical; }
.row > input:not([type="checkbox"]):not([type="file"]) { flex: 1; min-width: 160px; }

button {
  font: inherit;
  font-weight: 600;
  padding: 9px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
}
button:hover { background: var(--green-dark); }
button.secondary { background: #e9edef; color: var(--text); }
button.secondary:hover { background: #dfe3e5; }
button.danger { color: var(--danger); }
button.link { background: none; padding: 0; font-weight: 500; }
button.link:hover { text-decoration: underline; }

.hint, .muted { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--danger); font-size: 0.9rem; }
.error:empty { display: none; }
code { background: #f0f2f5; padding: 1px 5px; border-radius: 4px; }
a { color: var(--green); }

.connection { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.connection p { margin-top: 0; }
#qr { width: 240px; height: 240px; border: 1px solid var(--border); border-radius: 8px; }

.badge, .status {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #e9edef;
  color: var(--text);
  text-transform: capitalize;
}
.badge[data-status="open"] { background: #25d366; color: #fff; }
.badge[data-status="qr"], .badge[data-status="connecting"] { background: #ffd279; }
.status[data-status="running"], .status[data-status="sent"] { background: #d9fdd3; color: #0b6b3a; }
.status[data-status="completed"] { background: #d7ecff; color: #0b4f8a; }
.status[data-status="failed"], .status[data-status="cancelled"] { background: #fde2e1; color: var(--danger); }
.status[data-status="paused"], .status[data-status="pending"] { background: #fff1c9; color: #7a5600; }

.table-wrap { max-height: 360px; overflow: auto; margin-top: 14px; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { position: sticky; top: 0; background: #f7f8fa; }
tr:last-child td { border-bottom: 0; }

.campaign { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-top: 12px; }
.campaign .hint { margin: 8px 0 10px; }
.progress { height: 8px; background: #e9edef; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--green); transition: width 0.4s; }

.media-preview { margin-bottom: 12px; }
.media-preview img,
.media-preview video {
  display: block;
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ---------- Accounts, admin panel ---------- */
main.wide { width: min(100% - 32px, 1200px); }
main.auth { width: min(100% - 32px, 440px); }

.topbar nav { gap: 12px; }
.topbar .who { font-weight: 600; }
.nav-link { color: #fff; font-weight: 600; }
button.small { padding: 5px 12px; font-size: 0.85rem; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.tab { background: none; color: var(--muted); border-radius: 8px 8px 0 0; padding: 8px 12px; }
.tab:hover { background: #f0f2f5; }
.tab.active { color: var(--green-dark); box-shadow: inset 0 -3px 0 var(--green); }
.auth form button[type="submit"] { width: 100%; }
.auth .row button { flex: 1; }
.auth input { width: 100%; }

.notice { background: #e7f6ee; color: #0b6b3a; padding: 10px 12px; border-radius: 8px; font-size: 0.9rem; }
.banner { background: #fde2e1; color: var(--danger); padding: 12px 16px; border-radius: 10px; font-weight: 600; }

details.account { margin-top: 14px; }
details.account summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
details.account form { margin-top: 10px; }

select {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  min-width: 220px;
}
label.inline { display: flex; align-items: center; gap: 6px; margin: 0; flex: 0 0 auto; min-width: 0; }
label.inline input { width: 80px; }

.new-key { margin-top: 14px; padding: 12px; border-radius: 8px; background: #e7f6ee; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.new-key code { font-size: 0.95rem; word-break: break-all; background: #fff; }
code.key { font-size: 0.85rem; }

td.actions { white-space: nowrap; }
td.actions button + button { margin-left: 10px; }
.table-wrap.tall { max-height: 520px; }
.pill { background: #d7ecff; color: #0b4f8a; padding: 1px 7px; border-radius: 999px; font-size: 0.75rem; }
small.error { font-size: 0.8rem; }

.file-chip { margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; display: inline-block; }
.media-preview audio { width: 100%; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
  td.actions { white-space: normal; }
}
