:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #26241f;
  --muted: #77726a;
  --line: #e5e1da;
  --brand: #1f3a5f;
  --brand-ink: #ffffff;
  --ok-bg: #e8f3ec; --ok-ink: #1e6b3a;
  --err-bg: #fbeaea; --err-ink: #9b2c2c;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
a { color: var(--brand); }
h1 { font-size: 24px; margin: 24px 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.mt { margin-top: 20px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

.topbar { background: var(--brand); color: var(--brand-ink); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .3px; }
.brand span { font-weight: 400; opacity: .8; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 6px; opacity: .85; }
.topbar nav a.on, .topbar nav a:hover { background: rgba(255,255,255,.15); opacity: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.narrow { max-width: 460px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head-row h1 { margin-bottom: 8px; }

.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; margin: 0; }
.stat:hover { border-color: var(--brand); }
.stat-num { font-size: 28px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; }

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
input[readonly] { background: var(--bg); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9c8dc; border-color: var(--brand); }
form.inline select { width: auto; margin: 0; }

.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 16px; border-radius: 8px; font: inherit; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-block { width: 100%; }

.flash { padding: 12px 14px; border-radius: 8px; margin: 16px 0; }
.flash-ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash-error { background: var(--err-bg); color: var(--err-ink); }

.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #faf9f6; }
td a { text-decoration: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge-grey { background: #eeece8; color: #5b5750; }
.badge-blue { background: #e6eef8; color: #1f3a5f; }
.badge-green { background: var(--ok-bg); color: var(--ok-ink); }
.badge-gold { background: #fdf3d8; color: #7a5a00; }
.badge-red { background: var(--err-bg); color: var(--err-ink); }
.badge-purple { background: #efe8f8; color: #5b3b8c; }

.facts { white-space: normal; font-size: 14px; }
.email-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
details summary { cursor: pointer; color: var(--brand); margin: 6px 0 10px; }
.email-frame { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.login-box { max-width: 380px; margin: 12vh auto 0; }
.login-box h1 { margin-top: 0; }

@media (max-width: 800px) {
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  th:nth-child(2), td:nth-child(2), th:nth-child(4), td:nth-child(4) { display: none; }
}

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row form { margin: 0; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.flags { margin: 0 0 12px; padding: 0; list-style: none; }
.flags li { background: #fff6e5; color: #7a4d00; border-left: 3px solid #e0a100; padding: 7px 10px; margin-bottom: 6px; border-radius: 4px; font-size: 14px; }
.okline { color: var(--ok-ink); }
.err { color: var(--err-ink); }
.email-pick { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; }
.inline-status select { width: auto; margin: 0; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 4px; }

.flags-red li { background: var(--err-bg); color: var(--err-ink); border-left-color: #c53030; }
.btn-send { background: #1e6b3a; border-color: #1e6b3a; color: #fff; }
.btn-send:hover { filter: brightness(1.1); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.preview-wrap { background: var(--bg); border-radius: 8px; padding: 12px; text-align: center; }
.preview-desktop { width: 100%; height: 900px; }
.preview-phone { width: 390px; max-width: 100%; height: 780px; }

.card-highlight { border-color: #e0a100; background: #fffaf0; }
