/* Markit customer portal. One hand-written stylesheet, no build step.
   Calm neutrals, high contrast, system/Inter type. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f2f2ef;
  --border: #e4e4df;
  --border-strong: #d0d0c9;
  --text: #16181d;
  --text-2: #3d4149;
  --muted: #5b6069;
  --input-border: #8a8f97;
  --primary: #16181d;
  --primary-text: #ffffff;
  --accent: #1f9d55;          /* Mark's focus glow / approvals */
  --accent-soft: rgba(31, 157, 85, 0.14);
  --danger: #b42318;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --surface: #18191c;
    --surface-2: #1f2024;
    --border: #2a2c31;
    --border-strong: #3a3d43;
    --text: #f2f2f0;
    --text-2: #c9cbd0;
    --muted: #9da2ac;
    --input-border: #5c6068;
    --primary: #f2f2f0;
    --primary-text: #111214;
    --accent: #3ccf7f;
    --accent-soft: rgba(60, 207, 127, 0.16);
    --danger: #f97066;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-underline-offset: 2px; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.h1 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.h2 { font-size: 16px; font-weight: 600; }
.h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); margin: 0; }
.inline { display: inline; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 52px; padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-left { flex: 1; }
.topbar-right { flex: 1; justify-content: flex-end; }
.wordmark { font-weight: 700; font-size: 15px; text-decoration: none; letter-spacing: -0.02em; }
.crumb { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb::before { content: "/"; margin-right: 12px; color: var(--border-strong); }
.topbar-tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 12px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--surface-2); }

/* Layout */
.container { max-width: 880px; margin: 0 auto; padding: 32px 20px; }
.auth-wrap { min-height: calc(100vh - 52px); display: grid; place-items: center; padding: 24px; }

/* Surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card { width: 100%; max-width: 380px; padding: 28px; }
.empty-state {
  padding: 32px; text-align: center; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}

/* Lists */
.list { list-style: none; margin: 16px 0 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.list li + li { border-top: 1px solid var(--border); }
.list-link { font-weight: 500; text-decoration: none; }
a.list-link:hover { text-decoration: underline; }

/* Forms */
.field { display: block; }
.field-label { display: block; font-weight: 500; margin-bottom: 6px; }
input[type="email"], input[type="text"], textarea, select {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--input-border); border-radius: var(--radius-sm);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.text-link { font-weight: 500; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { resize: vertical; min-height: 40px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; font: inherit; font-weight: 500; line-height: 1.2;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { opacity: 0.88; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-approve { background: var(--accent); color: #fff; }
.btn-approve:hover { opacity: 0.9; }
.btn[disabled] { opacity: 0.5; cursor: default; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border); white-space: nowrap;
}
.badge-approved { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-passed { color: var(--muted); }

/* ---------- Campaign workspace: chat left, building blocks right ---------- */
body.app { height: 100vh; overflow: hidden; }
.crumb-strong { color: var(--text); font-weight: 500; max-width: 38vw; }
.workspace {
  display: grid; grid-template-columns: minmax(320px, 400px) 1fr;
  height: calc(100vh - 52px);
}
.chat {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--border);
}
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.avatar-mark {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: var(--primary-text); font-weight: 700; font-size: 13px;
}
.chat-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-mark .msg-text { background: var(--surface-2); padding: 10px 12px; border-radius: 4px 12px 12px 12px; }
.msg-user { align-self: flex-end; }
.msg-user .msg-text { background: var(--primary); color: var(--primary-text); padding: 10px 12px; border-radius: 12px 4px 12px 12px; }
.msg-system .msg-text { color: var(--muted); font-size: 12px; text-align: center; }
.msg-label { margin-bottom: 4px; }
.msg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg-status { color: var(--muted); font-size: 12px; font-style: italic; }
.composer { border-top: 1px solid var(--border); padding: 12px 14px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 40px; max-height: 160px; }

.panel { overflow-y: auto; padding: 20px 28px 48px; min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.back { text-decoration: none; color: var(--muted); font-weight: 500; }
.back:hover { color: var(--text); }

/* The creator Mark is talking about glows. It starts first and scrolls with the rest;
   clicking any card moves the glow (and Mark's take) there. */
.focus-slot { margin-bottom: 12px; }
.creator-card[data-focus-key] { cursor: pointer; }
.creator-card[data-focus-key]:not(.focused):hover { border-color: var(--border-strong); }
.card-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.js .card-focus-link { display: none; }
.card-list { display: grid; gap: 12px; }

.creator-card { padding: 16px 18px; }
.creator-card.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 6px 24px var(--accent-soft);
}
.card-top { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface-2); }
.avatar-empty { display: grid; place-items: center; font-weight: 600; color: var(--muted); }
.who { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.name { font-weight: 600; font-size: 15px; text-decoration: none; }
.name:hover { text-decoration: underline; }
.card-right { display: flex; align-items: center; gap: 10px; }
.score { display: flex; flex-direction: column; align-items: center; min-width: 54px; padding: 4px 8px; border-radius: var(--radius-sm); background: var(--surface-2); }
.score-n { font-weight: 700; font-size: 18px; line-height: 1.1; }
.score-l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.bio { margin: 10px 0 0; color: var(--text-2); overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px 16px; margin: 14px 0 0; }
.stats div { min-width: 0; }
.stats .wide { grid-column: span 2; }
.stats dt, .kv dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stats dd, .kv dd { margin: 2px 0 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.posts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.post { text-decoration: none; min-width: 0; }
.post img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.post-text { display: block; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.post-text .post-title { margin-top: 0; }
.post-text:hover { background: var(--surface-2); }
.posts-rows { grid-template-columns: 1fr; gap: 6px; }
.post-title { font-size: 12px; font-weight: 500; margin-top: 6px; line-height: 1.35; overflow-wrap: anywhere; }
.card-open { display: inline-block; margin-top: 12px; font-weight: 500; font-size: 13px; color: var(--muted); }
.card-open:hover { color: var(--text); }
.detail-section { padding: 16px 18px; margin-top: 12px; }
.detail-section .h3 { margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 20px; margin: 0; }
.kv dd { font-weight: 500; white-space: normal; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  /* Two-row top bar: wordmark, campaign and Sign out; then the tabs. Only the
     tabs stay pinned when scrolling: the first row (8px + 36px) slides away. */
  .topbar { flex-wrap: wrap; height: auto; row-gap: 0; padding: 8px 16px 0; top: -44px; }
  .topbar-left { order: 1; flex: 1 1 0; min-width: 0; height: 36px; gap: 10px; }
  .topbar-right { order: 2; flex: 0 0 auto; height: 36px; }
  .topbar-email, .crumb-team { display: none; }
  .crumb-strong { max-width: none; min-width: 0; }
  .topbar-tabs { order: 3; flex: 1 0 100%; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
  .topbar-tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex-shrink: 0; }
  /* Chat stacks above the panel: a real box, messages scroll inside, composer at its foot. */
  body.app { overflow: auto; height: auto; }
  .workspace { grid-template-columns: 1fr; height: auto; }
  .chat { border-right: 0; border-bottom: 1px solid var(--border); max-height: 45vh; min-height: 240px; }
  .chat-head { padding: 10px 16px; }
  .chat-body { flex: 1 1 auto; min-height: 96px; padding: 12px 16px; }
  .composer { flex-shrink: 0; }
  .panel { overflow: visible; padding: 16px 16px 40px; }
  .panel-head { flex-wrap: wrap; }
  .posts { grid-template-columns: repeat(2, 1fr); }
  .posts-rows { grid-template-columns: 1fr; }
}

/* Approve / pass in chat. They stay in view at the foot of the chat box while
   a long take (or chat history) scrolls behind them. */
.msg-actions form { display: inline; }
.chat-body .msg-mark[data-creator] .msg-actions {
  position: sticky; bottom: 0; z-index: 1;
  background: var(--surface); padding: 8px 0; margin-top: 0;
}
.msg-typing { color: var(--muted); font-style: italic; }
.msg-typing-note { margin-top: 4px; font-style: italic; }
.msg-error .msg-text { color: var(--danger); }
details.pass { display: inline-block; }
details.pass > summary { list-style: none; }
details.pass > summary::-webkit-details-marker { display: none; }
details.pass[open] { display: block; width: 100%; }
.pass-form { margin-top: 8px; display: grid; gap: 8px; }

/* Outreach */
.email-preview { margin-top: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.email-meta { margin-bottom: 4px; }
.email-subject { font-weight: 600; margin-bottom: 6px; }
.email-body { white-space: pre-wrap; font-size: 13px; color: var(--text-2); max-height: 280px; overflow-y: auto; }
.confirm { margin-top: 8px; color: var(--text-2); }
.toggle-form { display: flex; align-items: center; gap: 8px; }
.switch { width: 34px; height: 20px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2); position: relative; cursor: pointer; padding: 0; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: left .15s; }
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on .knob { left: 16px; background: #fff; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat-n { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.stat-l { font-size: 12px; color: var(--muted); }
.db-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.db-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); cursor: pointer; }
.chip.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.db-columns { position: relative; }
.db-columns-menu { position: absolute; right: 0; top: 34px; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; display: grid; gap: 4px; min-width: 160px; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.db-wrap { overflow-x: auto; }
table.db { width: 100%; border-collapse: collapse; font-size: 13px; }
table.db th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap; }
table.db th[data-dir="asc"]::after { content: " ↑"; }
table.db th[data-dir="desc"]::after { content: " ↓"; }
table.db td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.db td.cell-email { min-width: 160px; max-width: 260px; }
table.db tr:last-child td { border-bottom: 0; }
.status-sent, .status-drafted, .status-replied, .status-negotiating, .status-deal_agreed, .status-accepted, .status-paid, .status-content_delivered { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.status-failed, .status-bounced, .status-declined { color: var(--danger); }
@media (max-width: 900px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

/* Summary */
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 6px 0 14px; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; }
.progress-money { background: var(--primary); }
.progress-label { display: flex; justify-content: space-between; }

/* Conversation */
.bullet { display: block; padding-left: 14px; position: relative; }
.bullet::before { content: "•"; position: absolute; left: 2px; color: var(--muted); }
.msg-text a { color: inherit; text-decoration: underline; }
.composer textarea { flex: 1; }

/* Campaign list */
.list-search { display: flex; gap: 8px; margin-top: 8px; }
.list-search input[type="search"] {
  flex: 1; padding: 9px 11px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.list-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 12px; }
.list-pager { display: flex; gap: 16px; }
.list li > .small { white-space: nowrap; }
.stat-n.stat-none { font-size: 15px; font-weight: 600; color: var(--muted); padding: 5px 0 4px; }
