:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #dde1e7;
  --text: #12223a;
  --muted: #5b6880;
  --blue: #2f5bd8;
  --green: #0f9d58;
  --red: #d64545;
  --violet: #8b5cf6;
  --amber: #dd8a10;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
body.centered { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 32px; max-width: 520px; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 12px; }

.topbar { display: flex; align-items: baseline; gap: 16px; padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; }
.meta { color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 4px; padding: 10px 16px 0; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  border: 0; background: transparent; padding: 9px 14px; cursor: pointer;
  border-bottom: 2px solid transparent; color: var(--muted); font-size: 14px; white-space: nowrap;
}
.tabs button.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

main { padding: 20px; max-width: 1200px; }
.tab { display: none; }
.tab.active { display: block; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 18px; }
.hint { color: var(--muted); margin: -4px 0 14px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.tile .n { font-size: 26px; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 13px; }
.tile.warn { border-color: var(--red); }
.tile.warn .n { color: var(--red); }

.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; align-items: end; }
label { display: block; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
input, select, textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
label.check input { width: auto; margin: 0; }
textarea { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }

button {
  padding: 9px 16px; border: 1px solid var(--blue); background: var(--blue); color: #fff;
  border-radius: 8px; cursor: pointer; font: inherit;
}
button.ghost, .panel button[type="button"], #pull-users, #load-crm-fields, #prompts-reset {
  background: #fff; color: var(--blue);
}
button.danger { background: #fff; color: var(--red); border-color: var(--red); padding: 4px 10px; }
button:disabled { opacity: .5; cursor: not-allowed; }

.grid { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.grid th, .grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.grid input, .grid select { margin: 0; padding: 5px 8px; }
.grid td.narrow { width: 90px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filters button { background: #fff; color: var(--muted); border-color: var(--line); padding: 6px 12px; }
.filters button.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.done { background: #e6f6ed; color: var(--green); }
.badge.spam, .badge.error { background: #fdeaea; color: var(--red); }
.badge.quarantine { background: #f1e9ff; color: var(--violet); }
.badge.admin, .badge.skipped, .badge.duplicate { background: #eef0f4; color: var(--muted); }

.dump { background: #10141c; color: #cfd6e4; padding: 14px; border-radius: 8px; max-height: 320px; overflow: auto; font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #10141c; color: #fff; padding: 11px 20px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--red); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.found { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px;
         display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.found .who { font-weight: 600; }
.found .meta { color: var(--muted); font-size: 13px; }

.offer-template { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.offer-template .offer-remove { margin-top: 4px; }

