:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e6ea;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #ff7a18;
  --accent-ink: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --skip: #6b7280;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  --radius: 12px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f12;
    --surface: #16191e;
    --surface-2: #1d2127;
    --border: #2a2f37;
    --text: #e6e9ee;
    --muted: #9aa3af;
    --accent: #ff8c33;
    --accent-ink: #1a1205;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 8px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.warn { color: var(--warn); font-weight: 600; }
.error { color: var(--bad); }

/* ---------- login / standalone cards ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); padding: 32px;
  width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { font-size: 22px; margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.login-card input, .login-card button { font-size: 15px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 750;
  font-size: 17px; padding: 6px 8px 16px; letter-spacing: -.02em; }
.brand .dot { width: 11px; height: 11px; border-radius: 3px; background: var(--accent); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600;
  border: none; background: none; width: 100%; text-align: left; font-size: 14px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent); color: var(--accent-ink); }
.sidebar .spacer { flex: 1; }

.main { padding: 26px 30px; max-width: 1080px; width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.topbar h1 { font-size: 24px; margin: 0; }

/* ---------- controls ---------- */
input, select, textarea, button {
  font-family: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { width: 100%; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.45; }
label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
label.field input, label.field select, label.field textarea { font-weight: 400; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

button {
  cursor: pointer; font-weight: 650; background: var(--surface-2);
  transition: filter .12s, background .12s;
}
button:hover { filter: brightness(.97); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.danger { color: var(--bad); border-color: var(--border); }
button.ghost { background: none; }
button.sm { padding: 5px 9px; font-size: 13px; border-radius: 7px; }

/* ---------- cards / panels ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px;
}
.card h2 { font-size: 16px; }
.card .card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card .card-head h2 { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
td.actions { text-align: right; white-space: nowrap; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.sent, .badge.done, .badge.ok { color: var(--ok); }
.badge.failed, .badge.error, .badge.stopped, .badge.bounced { color: var(--bad); }
.badge.invalid, .badge.bad, .badge.paused { color: var(--warn); }
.badge.suppressed, .badge.skip, .badge.draft { color: var(--skip); }
.badge.running { color: var(--accent); }

/* ---------- progress ---------- */
.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.stat-row { display: flex; gap: 22px; flex-wrap: wrap; margin: 12px 0; }
.stat { display: flex; flex-direction: column; }
.stat .n { font-size: 24px; font-weight: 750; letter-spacing: -.02em; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* ---------- activity log ---------- */
.log {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  font-family: var(--mono); font-size: 12.5px; padding: 10px 12px; height: 260px;
  overflow-y: auto; white-space: pre-wrap; line-height: 1.6;
}
.log .l-ok { color: var(--ok); }
.log .l-error { color: var(--bad); }
.log .l-bad { color: var(--warn); }
.log .l-skip { color: var(--muted); }
.log .ts { color: var(--muted); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 9px 14px; cursor: pointer; font-weight: 650; color: var(--muted);
  border-bottom: 2px solid transparent; background: none; border-radius: 0; border-top: 0; border-left: 0; border-right: 0; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- preview frame ---------- */
.preview-frame { width: 100%; height: 520px; border: 1px solid var(--border); border-radius: 9px; background: #fff; }
.preview-text { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 14px; white-space: pre-wrap; font-family: var(--mono); font-size: 13px; max-height: 520px; overflow: auto; }

/* ---------- toast ---------- */
#toast { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  box-shadow: var(--shadow); border-radius: 9px; padding: 11px 15px; max-width: 360px; animation: slide .2s ease; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--bad); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.pill-group { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.pill-group button { border: none; border-radius: 0; background: var(--surface); }
.pill-group button.active { background: var(--accent); color: var(--accent-ink); }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .sidebar .spacer { display: none; }
  .main { padding: 18px 16px; }
}
