:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1c2430;
  --muted: #6b7684;
  --accent: #2456e6;
  --accent-soft: #e8eefc;
  --green: #1a9b62;
  --amber: #c07d10;
  --red: #cc3b3b;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; flex-shrink: 0; background: #10192b; color: #c6cede;
  padding: 20px 0; display: flex; flex-direction: column; gap: 2px;
}
.sidebar .brand {
  color: #fff; font-size: 17px; font-weight: 700; padding: 0 20px 18px;
  letter-spacing: .3px;
}
.sidebar .brand span { color: #6f9bff; }
.sidebar a {
  color: #c6cede; padding: 9px 20px; display: block; border-left: 3px solid transparent;
}
.sidebar a:hover { background: #182338; text-decoration: none; }
.sidebar a.active { background: #1b2a45; color: #fff; border-left-color: #6f9bff; }
.sidebar .foot { margin-top: auto; padding: 12px 20px; font-size: 12px; color: #5d6a80; }
.sidebar .foot a { padding: 0; display: inline; border: none; color: #8fa2c0; }

.main { flex: 1; padding: 26px 32px; max-width: 1200px; }
h1 { font-size: 21px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 22px 0 10px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.card .num { font-size: 24px; font-weight: 700; }
.card .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 18px;
}

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 9px 10px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7f9fd; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px;
  font-weight: 600; background: #eef0f3; color: var(--muted);
}
.badge.new { background: var(--accent-soft); color: var(--accent); }
.badge.engaged { background: #e2f6ec; color: var(--green); }
.badge.customer { background: #fdf1dd; color: var(--amber); }
.badge.unsub { background: #fdeaea; color: var(--red); }
.badge.sent { background: #e2f6ec; color: var(--green); }
.badge.draft { background: #eef0f3; color: var(--muted); }
.badge.on { background: #e2f6ec; color: var(--green); }
.badge.off { background: #fdeaea; color: var(--red); }

.score {
  display: inline-block; min-width: 34px; text-align: center; font-weight: 700;
  padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent);
}
.score.hot { background: #fdeaea; color: var(--red); }
.score.warm { background: #fdf1dd; color: var(--amber); }

button, .btn {
  font: inherit; border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
}
button:hover, .btn:hover { border-color: #c6ccd4; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1d49c8; }
button.danger { color: var(--red); }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea {
  font: inherit; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  width: 100%; background: #fff; color: var(--text);
}
textarea { min-height: 130px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.toolbar input, .toolbar select { width: auto; }
.toolbar .spacer { flex: 1; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: 10px 0 10px 26px; border-left: 2px solid var(--border); margin-left: 8px;
  position: relative;
}
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 16px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent); border: 2px solid #fff;
}
.timeline li.t-email_received::before { background: var(--green); }
.timeline li.t-email_open::before { background: var(--amber); }
.timeline li.t-link_click::before { background: var(--red); }
.timeline li.t-site_visit::before { background: #8a5be0; }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .what { font-weight: 600; }
.timeline .detail { color: var(--muted); font-size: 13px; word-break: break-all; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { width: 340px; }
.error { color: var(--red); margin-top: 10px; font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
pre.snippet {
  background: #10192b; color: #c9e3ff; padding: 12px 14px; border-radius: 8px;
  overflow-x: auto; font-size: 12.5px;
}
.msg-body {
  background: #f7f9fd; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-top: 6px; white-space: pre-wrap; font-size: 13px;
  max-height: 160px; overflow-y: auto;
}
.toast {
  position: fixed; bottom: 20px; right: 20px; background: #10192b; color: #fff;
  padding: 12px 18px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
  z-index: 50;
}
