/* Rankdough Reach. Tokens follow the original app (green primary, dark teal rail). */
:root {
  --radius: 8px;
  --bg: oklch(0.985 0.002 180);
  --fg: oklch(0.21 0.015 220);
  --card: #fff;
  --primary: oklch(0.435 0.072 182);
  --primary-fg: oklch(0.99 0.005 180);
  --primary-hover: oklch(0.38 0.072 182);
  --secondary: oklch(0.955 0.007 200);
  --muted: oklch(0.958 0.005 200);
  --muted-fg: oklch(0.45 0.018 215);
  --accent: oklch(0.945 0.02 182);
  --accent-fg: oklch(0.36 0.06 182);
  --destructive: oklch(0.52 0.2 25);
  --border: oklch(0.905 0.008 210);
  --linkedin: oklch(0.518 0.166 257);
  --success: oklch(0.5 0.12 155);
  --warning: oklch(0.6 0.14 70);
  --rail: oklch(0.225 0.024 200);
  --rail-fg: oklch(0.86 0.012 200);
  --rail-active: oklch(0.32 0.055 184);
  --orange: oklch(0.646 0.2 41);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; border-color: var(--border); }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.011em; }
p { margin: 0; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.boot { padding: 2rem 1rem; color: var(--muted-fg); }
.muted { color: var(--muted-fg); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.grow { flex: 1 1 auto; min-width: 0; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.right { text-align: right; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; width: 240px; flex: none; display: flex; flex-direction: column; background: var(--rail); padding: 16px 12px; }
.rail .brand { padding: 0 12px 20px; }
.rail .brand b { display: block; color: #fff; font-size: 14px; }
.rail .brand span { color: color-mix(in oklch, var(--rail-fg) 70%, transparent); font-size: 12px; }
.rail nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.rail-link { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 6px; padding: 8px 12px; color: var(--rail-fg); text-decoration: none; font-size: 14px; }
.rail-link:hover { background: rgb(255 255 255 / 0.06); }
.rail-link.active { background: var(--rail-active); color: #fff; font-weight: 500; }
.rail-link svg { width: 16px; height: 16px; flex: none; }
.rail-link .count { margin-left: auto; background: var(--primary); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; line-height: 18px; }
.main { flex: 1; min-width: 0; }
.topbar { display: none; }

/* Page */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 16px; border-bottom: 1px solid var(--border); background: var(--card); padding: 20px 32px; }
.page-head h1 { font-size: 18px; font-weight: 600; }
.page-head p { margin-top: 4px; max-width: 42rem; color: var(--muted-fg); }
.page-head .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-body { padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 24px; }

/* Cards and grids */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 20px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 14px; font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid > .card { height: 100%; }
.split { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 6px; border: 1px solid transparent; background: var(--primary); color: var(--primary-fg); cursor: pointer; font-weight: 500; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.outline { background: var(--card); color: var(--fg); border-color: var(--border); }
.btn.outline:hover { background: var(--muted); }
.btn.ghost { background: none; color: var(--fg); }
.btn.ghost:hover { background: var(--muted); }
.btn.danger { background: var(--destructive); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 30px; padding: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13px; }
label.field > .hint { font-weight: 400; color: var(--muted-fg); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], select, textarea {
  width: 100%; min-height: 36px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); padding: 6px 10px;
}
textarea { resize: vertical; line-height: 1.45; }
select { padding-right: 28px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.notice { border-radius: 6px; padding: 10px 12px; font-size: 13px; background: var(--muted); color: var(--muted-fg); }
.notice.error { background: color-mix(in oklch, var(--destructive) 10%, white); color: var(--destructive); }
.notice.ok { background: color-mix(in oklch, var(--success) 12%, white); color: var(--success); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 500; background: var(--muted); color: var(--muted-fg); white-space: nowrap; }
.badge.green { background: color-mix(in oklch, var(--success) 14%, white); color: var(--success); }
.badge.amber { background: color-mix(in oklch, var(--warning) 16%, white); color: oklch(0.45 0.1 70); }
.badge.red { background: color-mix(in oklch, var(--destructive) 10%, white); color: var(--destructive); }
.badge.blue { background: color-mix(in oklch, var(--linkedin) 10%, white); color: var(--linkedin); }
.badge.teal { background: var(--accent); color: var(--accent-fg); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted-fg); background: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }

/* Empty state */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px; }
.empty .ico { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); margin-bottom: 12px; }
.empty .ico svg { width: 20px; height: 20px; }
.empty b { font-size: 14px; }
.empty p { margin-top: 6px; max-width: 28rem; color: var(--muted-fg); }
.empty .actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* Sender cards */
.sender { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.sender dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; }
.sender dt { font-size: 12px; color: var(--muted-fg); }
.sender dd { margin: 0; font-weight: 500; }
.sender .foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; }

/* Steps and bubbles */
.step { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.step-head { display: flex; gap: 12px; align-items: flex-start; }
.step-num { width: 28px; height: 28px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-fg); font-weight: 600; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { border: 1px solid var(--border); border-radius: 4px; background: var(--card); padding: 1px 6px; font: 11px var(--mono); color: var(--muted-fg); cursor: pointer; }
.chip:hover { color: var(--fg); background: var(--muted); }
.bubble { max-width: 640px; border-radius: 14px; padding: 10px 14px; background: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.out { background: var(--primary); color: var(--primary-fg); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.in { border-bottom-left-radius: 4px; }
.bubble-meta { font-size: 11px; color: var(--muted-fg); margin: 2px 4px 0; }
.thread { display: flex; flex-direction: column; gap: 4px; padding: 16px; max-height: 60vh; overflow-y: auto; }
.thread .msg { display: flex; flex-direction: column; }
.thread .msg.out { align-items: flex-end; }

/* Lists with selection */
.pick { display: flex; flex-direction: column; }
.pick button { display: flex; flex-direction: column; gap: 2px; text-align: left; width: 100%; border: 0; border-bottom: 1px solid var(--border); background: var(--card); padding: 12px 16px; cursor: pointer; }
.pick button:last-child { border-bottom: 0; }
.pick button:hover { background: var(--muted); }
.pick button.on { background: var(--accent); }
.pick .t { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: none; }

/* Funnel */
.funnel { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.funnel > div { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--card); }
.funnel b { display: block; font-size: 22px; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--muted); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); }

/* KPI */
.kpi { padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font-size: 24px; font-weight: 600; line-height: 1.2; }

/* Chart */
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 11px var(--font); fill: var(--muted-fg); }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 3; }
.chart-wrap { position: relative; }
.chart-tip { position: absolute; pointer-events: none; background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 12px; box-shadow: 0 2px 8px rgb(0 0 0 / 0.1); white-space: nowrap; z-index: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-fg); }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid; }
.legend i.dash { border-top-style: dashed; }

/* Lead activity cards */
.bucket-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.lead-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.timeline { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--muted-fg); }
.lead-card .foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-form { display: flex; gap: 6px; width: 100%; }

/* Modal */
dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: var(--card); color: var(--fg); }
dialog::backdrop { background: rgb(15 30 30 / 0.45); }
dialog .m-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 18px 20px 0; }
dialog .m-head h2 { font-size: 16px; }
dialog .m-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
dialog .m-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }
ol.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
ol.steps li { display: flex; gap: 12px; }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--rail); color: #fff; border-radius: 8px; padding: 10px 14px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.25); max-width: 420px; }
.toast.error { background: var(--destructive); }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login .card { width: min(400px, 100%); padding: 28px; }
.login h1 { font-size: 20px; }

pre.code { margin: 0; background: var(--muted); border-radius: 6px; padding: 10px 12px; font: 12px/1.5 var(--mono); overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }

/* Mobile */
@media (max-width: 900px) {
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .shell { display: block; }
  .rail { position: fixed; z-index: 30; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform 150ms ease; height: 100dvh; }
  .rail.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 0.4); z-index: 20; }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 10; background: var(--rail); color: #fff; padding: 10px 16px; }
  .topbar b { font-size: 14px; }
  .topbar .btn { background: rgb(255 255 255 / 0.1); color: #fff; }
  .page-head, .page-body { padding-left: 16px; padding-right: 16px; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .grid.cols-2, .grid.cols-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
  .page-head .actions { width: 100%; }
  .page-head .actions > select { flex: 1 1 140px; }
  .sender dl { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 901px) and (max-width: 1180px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Additions */
.err-text { color: var(--destructive); }
.sender .row.top { flex-wrap: nowrap; align-items: center; }
.only-sm { display: none; }
.inbox { grid-template-columns: 340px minmax(0, 1fr); }
.card.pick { overflow: hidden; }
a.card { color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--primary); }
.card > .table-wrap:first-child table th:first-child { border-top-left-radius: var(--radius); }
.card .table-wrap { border-radius: 0 0 var(--radius) var(--radius); }
@media (max-width: 900px) {
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .inbox > :nth-child(2) { display: none; }
  .inbox.has-thread > :nth-child(1) { display: none; }
  .inbox.has-thread > :nth-child(2) { display: block; }
  .only-sm { display: inline-flex; }
}
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.empty b { font-size: 15px; }
.row select, .actions select { width: auto; min-width: 150px; max-width: 100%; }
.row input[type=search] { width: auto; flex: 1 1 220px; min-width: 180px; }
.card-head .row { justify-content: flex-end; }
@media (max-width: 900px) {
  .row select, .actions select, .row input[type=search] { flex: 1 1 100%; width: 100%; }
}
.map-table td:first-child { white-space: nowrap; }
.map-table select { min-width: 190px; }
.masked { -webkit-text-security: disc; text-security: disc; }
.grid.top { align-items: start; }
.grid.top > .card { height: auto; }
.nowrap-row { flex-wrap: nowrap; align-items: flex-start; }
.nowrap-row .badge { flex: none; }
@media (max-width: 900px) {
  .table-wrap > table { min-width: 560px; }
  .table-wrap td:first-child { min-width: 120px; }
}
.step-head { flex-wrap: wrap; }
.funnel { grid-template-columns: repeat(8, minmax(0, 1fr)); }
@media (max-width: 1100px) { .funnel { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 600px) { .funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
