/* Pen — "Ink & sand": warm off-white, white cards, black actions, colour only for status. */

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --soft: #f2f1ee;
  --line: #e6e4df;
  --line-soft: #f0eeea;
  --ink: #111111;
  --ink-2: #3a3a37;
  --muted: #7a7a75;
  --good: #2e7d5b;
  --good-bg: #e9f3ee;
  --attention: #a86a1f;
  --attention-bg: #fbf1e3;
  --bad: #b4432f;
  --bad-bg: #fbeae6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(17, 17, 17, 0.04);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-underline-offset: 2px; }
a:hover { color: var(--ink-2); }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 15px; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.eyebrow { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.stack { display: grid; gap: 16px; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ---------- Shell ---------- */

.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px; border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 700; font-size: 16px; padding: 0 8px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}

.nav { display: grid; gap: 2px; }
.nav a {
  display: block; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid transparent;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { color: var(--ink); background: var(--soft); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }

.sidebar-footer { margin-top: auto; display: grid; gap: 8px; padding: 0 8px; }
.user-line { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { padding: 40px 48px 64px; max-width: 1040px; width: 100%; }

/* ---------- Page header & stats ---------- */

.page-head, .topline { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head p, .topline p { margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 12.5px; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 0 10px; }

/* ---------- Cards, panels, tables ---------- */

.card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel { padding: 20px; }
.panel h2 { margin-bottom: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }

/* ---------- Buttons & pills ---------- */

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1;
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--ink); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .button:hover { background: #2b2b2b; color: #fff; }
button.secondary, .button.secondary, button.ghost, .button.ghost {
  background: var(--surface); color: var(--ink); border-color: var(--line);
}
button.secondary:hover, .button.secondary:hover, button.ghost:hover, .button.ghost:hover { background: var(--soft); color: var(--ink); }
button.danger, .button.danger { background: var(--surface); color: var(--bad); border-color: var(--line); }
button.danger:hover { background: var(--bad-bg); color: var(--bad); }
button.small, .button.small { padding: 7px 12px; font-size: 12.5px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.full-width { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }

.pill, .badge {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--soft); color: var(--ink-2);
}
.pill.good, .badge.ok { background: var(--good-bg); color: var(--good); }
.pill.attention, .badge.warn { background: var(--attention-bg); color: var(--attention); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip { display: inline-block; background: var(--soft); border-radius: 999px; padding: 2px 9px; margin: 2px 4px 2px 0; font-size: 12.5px; }

/* ---------- Lead list (Today / Sent) ---------- */

.lead-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.lead + .lead { border-top: 1px solid var(--line-soft); }

.lead > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
}
.lead > summary::-webkit-details-marker { display: none; }
.lead > summary:hover, .lead[open] > summary, .lead[open] { background: var(--surface-2); }
.lead.is-selected { box-shadow: inset 3px 0 0 var(--ink); }

.avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: #b8b8b2; color: #fff; font-size: 12px; font-weight: 600;
}
.lead-main { flex: 1; min-width: 0; }
.lead-main > span { display: block; }
.lead-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-title span { color: var(--muted); font-weight: 400; }
.lead-preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-side { display: flex; align-items: center; gap: 10px; flex: none; }
.lead-side form { margin: 0; }

.lead-body { padding: 4px 16px 18px 62px; display: grid; gap: 14px; }
.lead-meta { color: var(--muted); font-size: 12.5px; }
.lead-subject { font-weight: 600; }
.mail {
  white-space: pre-line; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 16px; color: var(--ink-2); font-size: 13.5px; line-height: 1.6;
}
.label { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.why { margin: 0; padding-left: 18px; color: var(--ink-2); }
.why li { margin: 3px 0; }
.why a { color: var(--muted); font-size: 12.5px; }
.actions details.edit > summary { list-style: none; }
.actions details.edit > summary::-webkit-details-marker { display: none; }
.actions details.edit[open] { flex-basis: 100%; display: grid; gap: 10px; }
.actions details.edit[open] > summary { justify-self: start; }
.edit-box { display: grid; gap: 10px; }
.edit-box textarea { min-height: 220px; }

.toast, .messages .message {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow);
}
.messages { display: grid; gap: 8px; margin-bottom: 18px; }
#draft-list .toast { margin-bottom: 12px; }

.empty {
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 28px; text-align: center; display: grid; gap: 6px; justify-items: center; color: var(--muted);
}
.empty strong { color: var(--ink); font-weight: 600; }

.callout {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.callout p { margin-top: 4px; }

/* ---------- Activity ---------- */

.search-leads { padding: 0 16px 16px; display: grid; gap: 0; }
.search-lead { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.search-lead .reason { color: var(--muted); }
.journey-lead > summary { list-style: none; cursor: pointer; }
.journey-lead > summary::-webkit-details-marker { display: none; }
.journey-lead > summary:hover span:first-child { text-decoration: underline; text-underline-offset: 2px; }
.journey { list-style: none; margin: 4px 0 12px; padding: 0 0 0 4px; display: grid; gap: 8px; }
.journey li { display: grid; grid-template-columns: 44px 18px minmax(0, 1fr); gap: 6px; font-size: 13px; color: var(--ink-2); }
.journey li::before { grid-column: 2; grid-row: 1; content: "✓"; color: var(--good); font-weight: 700; }
.journey li.mark-stopped::before { content: "✕"; color: var(--bad); }
.journey li.mark-current::before { content: "→"; color: var(--ink); }
.journey .time { grid-column: 1; grid-row: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
.journey .step { grid-column: 3; grid-row: 1; display: grid; gap: 4px; }
.todo { color: var(--muted); font-size: 12.5px; }
details.tech > summary { list-style: none; cursor: pointer; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
details.tech > summary::-webkit-details-marker { display: none; }
details.tech code { display: block; margin-top: 6px; padding: 8px 10px; background: var(--soft); border-radius: 8px; font-size: 12px; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; }
.problem { padding: 14px 16px; display: grid; gap: 4px; font-size: 13.5px; }
.problem + .problem { border-top: 1px solid var(--line-soft); }
.find-more { display: flex; align-items: flex-end; gap: 8px; }
.find-more label { font-size: 12.5px; color: var(--muted); display: grid; gap: 4px; }
.find-more input { width: 84px; }
.find-more .hint { font-size: 12px; color: var(--muted); }

/* ---------- Contacts ---------- */

.import-panel { margin-bottom: 16px; padding: 0; }
.import-panel > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.import-panel > summary::-webkit-details-marker { display: none; }
.import-panel > form { padding: 0 16px 18px; }
.choice { border: none; margin: 0 0 6px; padding: 0; display: grid; gap: 8px; }
.choice legend { font-size: 13px; font-weight: 500; margin-bottom: 6px; padding: 0; }
.choice label { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; margin: 0; }
.choice label:has(input:checked) { border-color: var(--ink); background: var(--surface-2); }
.choice label > span { display: grid; gap: 2px; }
.choice input { margin-top: 3px; accent-color: var(--ink); }
.contacts-search { margin-bottom: 10px; }
.contacts-search input { max-width: 420px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filters .pill { text-decoration: none; padding: 5px 11px; }
.filters .pill span { color: var(--muted); margin-left: 2px; }
.filters .pill.is-active { background: var(--ink); color: #fff; }
.filters .pill.is-active span { color: rgba(255, 255, 255, 0.7); }
.contact-source { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.activity-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.activity-filter select, .activity-filter input[type="date"] { width: auto; min-width: 170px; }
.period-summary { margin: 0 0 12px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }

/* ---------- Forms ---------- */

form { margin: 0; }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="time"],
input[type="url"], input[type="search"], input:not([type]), select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.06); }
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ink); }
input[type="file"] { font: inherit; font-size: 13px; }
.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field.is-check { display: flex; align-items: center; gap: 8px; }
.field.is-check label { margin: 0; order: 2; }
.helptext { color: var(--muted); font-size: 12px; }
.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--bad); font-size: 12.5px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ---------- Settings ---------- */

.settings { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 28px; align-items: start; }
.settings-index { position: sticky; top: 28px; display: grid; gap: 2px; }
.settings-index a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 13.5px; }
.settings-index a:hover { color: var(--ink); background: var(--soft); }
.settings-sections { display: grid; gap: 14px; }
.setting { scroll-margin-top: 24px; padding: 18px 20px; }
.setting-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.setting-head p { margin-top: 2px; }
.summary-list { margin: 0; display: grid; }
.summary-list div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 13.5px; }
.summary-list div:first-child { border-top: none; }
.summary-list dt { color: var(--muted); flex: none; white-space: nowrap; }
.summary-list dd { margin: 0; text-align: right; }
.setting details { margin-top: 12px; }
.setting-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: flex-start; }
.setting-actions details { margin-top: 0; }
.setting-actions > form button, .setting-actions > .button { padding: 7px 14px; font-size: 13px; }
.setting-actions details[open] { flex-basis: 100%; order: 10; }
.setting details > summary {
  list-style: none; cursor: pointer; display: inline-flex; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
}
.setting details > summary::-webkit-details-marker { display: none; }
.setting details[open] > summary { margin-bottom: 14px; }
.asset-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.asset-row:first-child { border-top: none; }

/* ---------- Onboarding & public pages ---------- */

.onboarding { max-width: 640px; margin: 0 auto; }
.steps { display: flex; gap: 6px; margin: 18px 0 22px; }
.steps span { height: 4px; flex: 1; border-radius: 999px; background: var(--line); }
.steps span.is-complete, .steps span.is-active { background: var(--ink); }
.steps span.is-active { opacity: 0.55; }
.onboarding .panel { padding: 24px; }
.onboarding-note { margin-top: 16px; color: var(--muted); font-size: 12.5px; }
.setup-grid { display: grid; gap: 24px; }
.subsection { display: grid; gap: 10px; }
.subsection + .subsection { border-top: 1px solid var(--line-soft); padding-top: 22px; }
.status-card { background: var(--soft); border-radius: var(--radius-sm); padding: 12px 14px; display: grid; gap: 2px; font-size: 13px; }
.status-card span { color: var(--muted); }
.status-card.is-ready { background: var(--good-bg); }
.status-card.is-ready strong { color: var(--good); }
.asset-list { display: grid; }

.public { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.public-card { width: 100%; max-width: 420px; }
.public-card .brand { justify-content: center; margin-bottom: 22px; padding: 0; }
.public-card .panel { padding: 26px; }
.public-card h1 { font-size: 22px; margin-bottom: 4px; }
.public-card .alt { margin-top: 14px; text-align: center; font-size: 13px; color: var(--muted); }

/* ---------- Email preview ---------- */

.preview-card { padding: 0; overflow: hidden; }
.preview-headers { margin: 0; padding: 16px 20px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; font-size: 13px; }
.preview-headers div { display: flex; gap: 12px; }
.preview-headers dt { width: 56px; color: var(--muted); }
.preview-headers dd { margin: 0; }
.preview-subject { padding: 18px 20px 0; }
.preview-body { margin: 0; padding: 14px 20px 20px; white-space: pre-wrap; font: inherit; font-size: 14px; line-height: 1.65; color: var(--ink-2); }
.preview-foot { border-top: 1px solid var(--line); padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Phone & small screens ---------- */

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; height: auto; flex-direction: row; align-items: center; gap: 10px;
    padding: 10px 12px; border-right: none; border-bottom: 1px solid var(--line); background: var(--bg); z-index: 5;
  }
  .brand span:last-child { display: none; }
  .nav { display: flex; gap: 2px; overflow-x: auto; }
  .nav a { padding: 6px 10px; white-space: nowrap; }
  .sidebar-footer { display: none; }
  .main { padding: 22px 16px 48px; }
  h1 { font-size: 23px; }
  .page-head, .topline { flex-direction: column; align-items: stretch; }
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat b { font-size: 19px; }
  .lead-preview { display: none; }
  .lead-side .pill, .contact-source { display: none; }
  .lead-body { padding: 4px 14px 16px; }
  .settings { grid-template-columns: 1fr; }
  .settings-index { position: static; display: flex; overflow-x: auto; }
  .grid-two { grid-template-columns: 1fr; }
  .callout { flex-direction: column; align-items: stretch; }
  .search-lead { flex-direction: column; gap: 2px; }
}

/* Plan & billing */
.plan-line { display: block; margin: -4px 0 10px; font-size: 12px; color: var(--muted); text-decoration: none; }
.plan-line:hover { color: var(--ink); }
.usage { margin-bottom: 16px; padding: 18px 20px; }
.usage h2 { margin-bottom: 4px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 10px; }
.plan { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; }
.plan.is-current { border-color: var(--ink); }
.plan-price b { font-size: 24px; }
.plan form, .plan button, .plan .pill { margin-top: auto; }
.plan .pill { align-self: flex-start; }
.problem-note { margin-top: 8px; color: var(--attention-ink, #8a5a12); }
