:root {
  --ink: #16181d;
  --ink-soft: #4b5160;
  --muted: #8b92a3;
  --line: #e6e8ee;
  --canvas: #f6f7f9;
  --surface: #ffffff;
  --accent: #0071bc;
  --accent-dark: #005a96;
  --green: #12885a;
  --green-bg: #e7f6ef;
  --amber: #b26a00;
  --amber-bg: #fdf3e2;
  --red: #d64545;
  --red-bg: #fbeaea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(22, 24, 29, 0.04), 0 4px 16px rgba(22, 24, 29, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, .brand {
  font-family: "Plus Jakarta Sans", -apple-system, sans-serif;
  letter-spacing: -0.01em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  background: var(--ink);
  color: #c9cedb;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  padding: 6px 10px 18px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(0,113,188,.25);
}
.nav-link {
  color: #c9cedb;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  display: block;
}
.nav-link:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--accent); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { font-size: 12px; color: var(--muted); padding: 10px; }

.main { flex: 1; min-width: 0; }
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}
.topbar .page-title { font-weight: 700; font-size: 17px; }
.content { padding: 28px; max-width: 1080px; }

/* ---------- Cards & stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .n { font-family: "Plus Jakarta Sans", sans-serif; font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.warn .n { color: var(--amber); }
.stat.bad .n { color: var(--red); }
.stat.good .n { color: var(--green); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.card-head h2 { margin: 0; font-size: 15px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
td .sub { color: var(--muted); font-size: 12px; }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.sent { background: var(--green-bg); color: var(--green); }
.pill.pending { background: var(--amber-bg); color: var(--amber); }
.pill.failed { background: var(--red-bg); color: var(--red); }
.pill.skipped, .pill.duplicate { background: #eef0f4; color: var(--ink-soft); }
.pill.on { background: var(--green-bg); color: var(--green); }
.pill.off { background: #eef0f4; color: var(--muted); }
.pill.trigger { background: #e8f1fb; color: var(--accent-dark); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--canvas); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid var(--red-bg); }
.btn.danger:hover { background: var(--red-bg); }
.btn.sm { padding: 6px 11px; font-size: 13px; }

.row-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 5px; }
.field input[type=text], .field input[type=number], .field input[type=password],
.field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
}
.field textarea { resize: vertical; }
.field.check { display: flex; align-items: center; gap: 9px; }
.field.check label { margin: 0; }
.field.check input { width: 18px; height: 18px; }
.errorlist { color: var(--red); font-size: 13px; margin: 6px 0 0; padding-left: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }

/* ---------- Messages ---------- */
.msg { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.msg.success { background: var(--green-bg); color: var(--green); }
.msg.error { background: var(--red-bg); color: var(--red); }
.msg.info { background: #e8f1fb; color: var(--accent-dark); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }

/* ---------- Flow chip (signature) ---------- */
.flow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.flow b { color: var(--ink); }
.flow .arrow { color: var(--accent); font-weight: 700; }

/* ---------- Auth ---------- */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; }
.auth-card .brand { font-size: 22px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 9px; }
.auth-card p.tag { color: var(--muted); margin-top: 0; margin-bottom: 24px; font-size: 14px; }
.auth-card .btn { width: 100%; justify-content: center; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }

@media (max-width: 720px) {
  .sidebar { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 18px; }
}
