:root {
  --blue: #0093dd;
  --blue-dark: #0077b5;
  --pink: #dd137b;
  --pink-dark: #b80f66;
  --ink: #1c2430;
  --muted: #667085;
  --line: #e3e8ef;
  --bg: #f4f7fb;
  --card: #ffffff;
  --ok: #12a150;
  --err: #d92d20;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
code { background: #eef3f9; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

.topbar { background: #fff; border-bottom: 4px solid var(--blue); box-shadow: 0 2px 8px rgba(0,0,0,.04); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 14px; height: 76px; }
.logo { height: 54px; }
.app-name { font-weight: 700; font-size: 20px; color: var(--pink); letter-spacing: .5px; }
.tabs { margin-left: auto; display: flex; gap: 6px; }
.tab { border: 0; background: transparent; padding: 10px 16px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab:hover { background: #eef6fc; color: var(--blue-dark); }
.tab.active { background: var(--blue); color: #fff; }

main.wrap { padding-top: 24px; padding-bottom: 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(16,24,40,.04); }
h2 { margin: 0 0 12px; font-size: 19px; display: flex; align-items: center; gap: 10px; }
.step { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--pink); color: #fff; font-size: 15px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }

label { display: block; font-weight: 600; font-size: 13.5px; color: #344054; margin-bottom: 12px; }
input[type=text], input[type=email], input[type=number], input[type=password], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; font-weight: 400; color: var(--ink);
  border: 1px solid #cfd6df; border-radius: 8px; background: #fff;
}
textarea { font-family: Consolas, "Cascadia Mono", monospace; font-size: 14px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,147,221,.15); }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
label.check input { width: auto; margin: 0; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.span2 { grid-column: span 2; }
.row { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: center; margin-bottom: 10px; }
.gap-s { gap: 10px; }
.narrow { width: 260px; }
.input-suffix { display: flex; gap: 6px; }
.input-suffix input { width: 110px; }
.input-suffix select { width: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; margin: 0; }
.btn.small { padding: 6px 12px; font-size: 13.5px; }
.btn.primary { background: var(--pink); color: #fff; }
.btn.primary:hover { background: var(--pink-dark); }
.btn.ghost { background: #fff; border-color: #cfd6df; color: var(--ink); }
.btn.ghost:hover { border-color: var(--blue); color: var(--blue-dark); }
.btn.danger { background: var(--err); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.seg { display: inline-flex; border: 1px solid #cfd6df; border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 16px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--blue); color: #fff; }

.drop { position: relative; display: block; border: 2px dashed #b9c6d6; border-radius: 10px; padding: 26px; text-align: center; font-weight: 400; color: var(--muted); cursor: pointer; background: #fafcfe; }
.drop:hover, .drop.over { border-color: var(--blue); background: #eef7fd; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop strong { color: var(--blue-dark); }

.stats { font-size: 14px; color: var(--muted); padding-bottom: 14px; }
.stats b { color: var(--ink); }
.table-wrap { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #f6f8fb; position: sticky; top: 0; }
th.email-col, td.email-col { background: #eef7fd; }
tr.bad td { color: var(--err); }
tr.dup td { color: #b54708; }
td.num { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.chip { border: 1px solid #b9dcf2; background: #eef7fd; color: var(--blue-dark); border-radius: 20px; padding: 2px 10px; cursor: pointer; font: inherit; font-size: 13px; }
.chip:hover { background: var(--blue); color: #fff; }

.preview-head { font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
#html-preview { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.summary { padding-bottom: 14px; font-size: 14px; color: var(--muted); flex: 1; min-width: 240px; }
.summary b { color: var(--ink); }

.progress { height: 14px; background: #e8edf3; border-radius: 10px; overflow: hidden; margin: 18px 0 6px; }
.bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--pink)); transition: width .4s; }
.small-text { font-size: 13.5px; color: var(--muted); }
.log { margin-top: 10px; max-height: 320px; overflow: auto; background: #0f1722; color: #d0d7e2; border-radius: 8px; padding: 10px 12px; font: 12.5px/1.6 Consolas, monospace; }
.log .ok { color: #6fe3a1; }
.log .error { color: #ff8a80; }
.log .info { color: #8fc9f0; }
.log .t { color: #6b7a8f; margin-right: 8px; }

.notice { padding: 12px 14px; border-radius: 8px; margin: 14px 0 0; font-size: 14px; }
.notice.warn { background: #fff6e6; border: 1px solid #f5c97a; margin: 0 0 20px; }
.notice.ok { background: #eafbf1; border: 1px solid #9ee0b9; color: #0b6b36; }
.notice.err { background: #fdecea; border: 1px solid #f3a59d; color: #a3170d; }
.test-row { margin-top: 14px; }
.test-row input { width: 280px; margin: 0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 50; }
.toast.err { background: var(--err); }

@media (max-width: 680px) {
  .grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .topbar-inner { height: auto; padding: 10px 16px; flex-wrap: wrap; }
  .tabs { margin-left: 0; }
  .logo { height: 40px; }
}

/* Historia */
.search { width: 300px; margin: 0; }
select.auto { width: auto; margin: 0; }
.table-wrap.tall { max-height: 520px; }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover td { background: #eef7fd; }
td.subj { white-space: normal; min-width: 220px; font-weight: 600; }
.badge { display: inline-block; padding: 1px 9px; border-radius: 20px; font-size: 12.5px; font-weight: 600; }
.badge.finished, .badge.sent { background: #eafbf1; color: #0b6b36; }
.badge.running { background: #eef7fd; color: var(--blue-dark); }
.badge.stopped, .badge.interrupted, .badge.pending { background: #fff6e6; color: #93370d; }
.badge.error { background: #fdecea; color: #a3170d; }
.hd-title { margin-top: 16px; }
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 18px; font-size: 13.5px; color: var(--muted); margin-bottom: 14px; }
.meta b { color: var(--ink); font-weight: 600; }
.hd-actions { margin-bottom: 8px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
#hd-html { width: 100%; height: 380px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.msg-text { white-space: pre-wrap; background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font: 14px/1.5 inherit; margin: 0; max-height: 380px; overflow: auto; font-family: "Segoe UI", system-ui, sans-serif; }
.btn.danger-ghost { background: #fff; border-color: #f3a59d; color: var(--err); }
.btn.danger-ghost:hover { background: #fdecea; }
.hist-sum td { white-space: nowrap; }
@media (max-width: 680px) { .search { width: 100%; } }

/* Wersja PHP: logowanie, wylogowanie, tryb wysyłki */
.logout-form { display: inline; margin: 0; }
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; text-align: center; }
.auth-card form { text-align: left; margin-top: 10px; }
.auth-card h2 { justify-content: center; margin-top: 12px; }
.auth-logo { height: 70px; }
.btn.wide { width: 100%; margin-top: 4px; }
.mode-note { margin: 0 0 14px; }
.auth-card .notice.warn { margin: 0 0 14px; }
input[readonly] { background: #f6f8fb; font-family: Consolas, monospace; font-size: 13px; }
