:root {
  --bg: #f4f7f6;
  --card: #fff;
  --ink: #033239;
  --muted: #5a6f74;
  --accent: #17be8a;
  --accent-ink: #033239;
  --danger: #c62828;
  --warn: #ed6c02;
  --border: #d5e0e2;
  --shadow: 0 8px 24px rgba(3,50,57,.08);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
.topbar {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 14px 18px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10;
}
.topbar h1 { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: .02em; }
.topbar .sub { opacity: .75; font-size: .8rem; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.btn {
  border: 0; border-radius: 999px; padding: 10px 16px; cursor: pointer; font-weight: 600;
  background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(.97); }
.btn.ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn.ink { background: var(--ink); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 6px 12px; font-size: .85rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 1rem; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  background: #e8f5f1; color: var(--ink);
}
.badge.emailed { background: #d8f5ea; color: #0b6b4f; }
.badge.rejected { background: #fdecea; color: var(--danger); }
.badge.needs, .badge.queued, .badge.looking { background: #fff4e5; color: #9a5b00; }
.badge.error { background: #fdecea; color: var(--danger); }
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, #033239 0%, #0a4d57 45%, #17be8a 140%);
}
.login-card { width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 6px; color: var(--ink); font-size: 1.35rem; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
label { display: block; font-size: .85rem; font-weight: 600; margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; padding: 12px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
textarea { min-height: 120px; resize: vertical; }
.err { color: var(--danger); font-size: .9rem; margin-top: 10px; min-height: 1.2em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button {
  border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 600;
}
.tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.hidden { display: none !important; }
.lead-link { color: var(--ink); font-weight: 700; text-decoration: none; }
.lead-link:hover { color: #0b6b4f; }
.modal {
  position: fixed; inset: 0; background: rgba(3,50,57,.45); display: grid; place-items: end center; padding: 12px; z-index: 50;
}
.modal .sheet {
  width: min(720px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 18px 18px 12px 12px;
  padding: 16px; box-shadow: var(--shadow);
}
.msg { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin: 8px 0; background: #fafcfb; }
.msg.out { border-left: 4px solid var(--accent); }
.msg.in { border-left: 4px solid var(--ink); }
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 999px; z-index: 80; font-weight: 600;
}
@media (max-width: 700px) {
  .table-wrap { overflow-x: auto; }
  .topbar h1 { font-size: .95rem; }
}

label { display:block; margin:10px 0 4px; font-size:.85rem; font-weight:600; color:var(--muted); }
input, select, textarea { width:100%; padding:10px 12px; border:1px solid var(--border); border-radius:10px; background:#fff; }
.row { display:flex; gap:10px; align-items:center; }
.err { color:var(--danger); margin-top:8px; font-size:.9rem; }
code { font-size:.85rem; background:#eef4f5; padding:2px 6px; border-radius:6px; }
.sheet { max-width:720px; }

/* Client leads: readable on narrow phones */
@media (max-width: 640px) {
  .wrap { padding: 12px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 520px; font-size: .85rem; }
  .table th, .table td { padding: 8px 6px; }
  .topbar { padding: 12px 14px; }
  .topbar h1 { font-size: .95rem; }
}

/* Brand colour swatches */
.swatches { display:flex; flex-wrap:wrap; gap:8px; margin:8px 0 12px; }
.swatch {
  width:36px; height:36px; border-radius:8px; border:2px solid #fff;
  box-shadow:0 0 0 1px var(--border); cursor:pointer; padding:0;
}
.swatch.selected { box-shadow:0 0 0 2px var(--ink); }
.swatch-label { font-size:.72rem; color:var(--muted); margin-top:2px; text-align:center; max-width:72px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.preset-row { display:flex; flex-wrap:wrap; gap:8px; margin:8px 0 12px; }
.preset-chip {
  display:inline-flex; align-items:center; gap:8px; padding:6px 10px; border-radius:999px;
  border:1px solid var(--border); background:#fff; cursor:pointer; font-size:.82rem; font-weight:600;
}
.preset-chip .dots { display:flex; gap:4px; }
.preset-chip .dot { width:14px; height:14px; border-radius:50%; border:1px solid rgba(0,0,0,.12); }
.contrast-note { font-size:.82rem; padding:8px 10px; border-radius:8px; background:#f8fafc; border:1px solid var(--border); margin:8px 0; }
.contrast-note.ok { background:#ecfdf5; border-color:#a7f3d0; }
.contrast-note.warn { background:#fff7ed; border-color:#fed7aa; }
.preview-frame {
  border:1px solid var(--border); border-radius:12px; background:#fff; min-height:280px;
  padding:12px; overflow:auto; max-height:520px;
}
.tpl-grid { display:grid; gap:14px; grid-template-columns:1fr; }
@media (min-width:900px){ .tpl-grid { grid-template-columns:1fr 1fr; } }
