/* MailFlow — design tokens */
:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #5b6578;
  --ink-3: #94a0b4;
  --line: #e6eaf2;
  --line-2: #eef1f6;
  --blue: #1a6dff;
  --blue-2: #0f5ae6;
  --blue-soft: #eaf1ff;
  --navy: #0f1d40;
  --navy-2: #0a1530;
  --green: #16a34a;
  --green-soft: #e7f8ee;
  --amber: #f59e0b;
  --red: #ef4444;
  --red-soft: #fdecec;
  --pink: #ec4899;
  --purple: #8b5cf6;
  --cyan: #0ea5e9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; display: flex; min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
svg.i { flex-shrink: 0; vertical-align: middle; }

/* ---------------------------------------------------------------- sidebar */
.sidebar { width: 250px; flex-shrink: 0; background: linear-gradient(180deg, #0f1c42 0%, #0a1431 100%); color: #c8d1e6; padding: 22px 16px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: block; padding: 0 6px 26px; }
.brand img { width: 196px; height: auto; display: block; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 14px; color: #c8d1e6; padding: 12px 14px; border-radius: 10px; font-weight: 500; font-size: 15px; }
.sidebar nav a svg { opacity: .85; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: linear-gradient(90deg, #1a6dff, #2a7bff); color: #fff; box-shadow: 0 6px 16px rgba(26, 109, 255, .35); }
.sidebar nav a.active svg { opacity: 1; }
.sidebar hr { border: 0; border-top: 1px solid rgba(255, 255, 255, .09); margin: 12px 4px; }

/* ---------------------------------------------------------------- main */
.main { flex: 1; min-width: 0; padding: 30px 34px 48px; }
body.full-bleed .main { padding: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); }
.flash { display: flex; align-items: center; gap: 8px; background: var(--green-soft); border: 1px solid #bfe9cf; color: #11663a; padding: 10px 14px; border-radius: 10px; margin-bottom: 18px; }
.flash.error { background: var(--red-soft); border-color: #f7c5c5; color: #b91c1c; }
body.full-bleed .flash { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); z-index: 50; box-shadow: var(--shadow-lg); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 1100px) { .grid-2, .grid-3, .grid-sidebar { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; }
.stat .si { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); flex-shrink: 0; }
.stat b { display: block; font-size: 22px; letter-spacing: -.02em; }
.stat span { color: var(--ink-2); font-size: 12px; }

/* ---------------------------------------------------------------- tables */
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfe; }
.table .actions { text-align: right; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: #f7f9fc; border-color: #d7deea; text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-2); border-color: var(--blue-2); }
.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-navy:hover { background: #18295a; border-color: #18295a; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #12873d; border-color: #12873d; }
.btn-danger { color: var(--red); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #f1f4f9; border-color: transparent; }
.btn-icon { padding: 8px; }
.inline { display: inline; }
label { display: block; font-weight: 600; font-size: 13px; color: var(--ink); margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; border: 1px solid #dfe4ee; border-radius: 9px; padding: 9px 12px; font: inherit; background: #fff; color: var(--ink);
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230f172a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--blue-soft); border-color: var(--blue); }
input[type=color] { width: 60px; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; color: var(--ink); margin: 8px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--blue); }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.row > .btn, .row > .shrink { flex: 0 0 auto; min-width: 0; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.input-icon input { padding-left: 34px; }

/* ---------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #f1f5f9; color: var(--ink-2); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.Running, .badge.Active, .badge.Completed { background: var(--green-soft); color: var(--green); }
.badge.Waiting { background: #fff7e6; color: #b45309; }
.badge.Paused, .badge.Draft, .badge.Exited { background: #f1f5f9; color: #64748b; }
.badge.Failed { background: var(--red-soft); color: #dc2626; }
.box-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; background: color-mix(in srgb, var(--c, #1a6dff) 11%, white); color: color-mix(in srgb, var(--c, #1a6dff) 80%, black); border: 1px solid color-mix(in srgb, var(--c, #1a6dff) 28%, white); margin: 1px 2px; }
.box-chip::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--c, #1a6dff); }
.empty { text-align: center; padding: 40px 16px; color: var(--ink-2); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.feed li:last-child { border-bottom: 0; }
.feed .dot { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; background: var(--blue-soft); color: var(--blue); }
.feed .dot.EmailSent { background: #f1ebff; color: var(--purple); }
.feed .dot.Opened { background: #e6f6fd; color: var(--cyan); }
.feed .dot.Clicked, .feed .dot.Replied { background: var(--green-soft); color: var(--green); }
.feed .dot.Error, .feed .dot.Unsubscribed { background: var(--red-soft); color: var(--red); }

.settings-list { display: grid; grid-template-columns: 220px 1fr; gap: 0; }
.settings-list > div { padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.settings-list > div:nth-child(odd) { color: var(--ink-2); }
.bar { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 99px; }

/* node type colours (shared) */
.t-box { background: #2f6bff; } .t-research { background: #0ea5e9; } .t-email { background: #8b5cf6; }
.t-wait { background: #f59e0b; } .t-condition { background: #ec4899; } .t-score { background: #10b981; } .t-end { background: #334155; }
.tile { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.tile.lg { width: 44px; height: 44px; border-radius: 12px; }

/* ================================================================ Flow builder */
.builder { display: grid; grid-template-columns: 236px minmax(0, 1fr) 360px; grid-template-rows: 64px minmax(0, 1fr); height: 100vh; }
.builder-top { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line); }
.crumbs { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.crumbs a { color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.crumbs .sep { color: var(--ink-3); }
.crumbs .title { font-weight: 700; font-size: 18px; color: var(--ink); letter-spacing: -.01em; }
.builder-top .spacer { flex: 1; }
.metrics { display: flex; align-items: center; gap: 26px; padding-right: 18px; margin-right: 4px; border-right: 1px solid var(--line); }
.metric { display: flex; align-items: center; gap: 10px; }
.metric svg { color: var(--blue); }
.metric.reply svg { color: var(--green); }
.metric b { display: block; font-size: 16px; line-height: 1.1; }
.metric span { font-size: 11.5px; color: var(--ink-2); }
.save-state { font-size: 12px; color: var(--ink-3); }

.palette { background: #fff; border-right: 1px solid var(--line); padding: 18px 16px; overflow: auto; }
.palette h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin-bottom: 12px; }
.palette .input-icon { margin-bottom: 14px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; cursor: grab; background: #fff; user-select: none; transition: border-color .15s, box-shadow .15s; position: relative; }
.palette-item:hover { border-color: #b9cdf6; box-shadow: var(--shadow); }
.palette-item .tile { width: 40px; height: 40px; border-radius: 11px; }
.palette-item b { display: block; font-size: 14px; }
.palette-item small { display: block; color: var(--ink-2); font-size: 12px; line-height: 1.35; }
.palette-item .drag { display: block; color: var(--ink-3); font-size: 11px; margin-top: 3px; }
.palette-item .grip { position: absolute; right: 10px; bottom: 10px; color: #b5bfcf; }
.palette .hint { display: flex; gap: 10px; font-size: 12px; color: var(--ink-2); line-height: 1.5; margin-top: 14px; background: #f7f9fc; border: 1px solid var(--line-2); border-radius: 12px; padding: 12px; }
.palette .hint svg { color: var(--amber); }

#canvas { position: relative; background-color: #f7f9fc; background-image: radial-gradient(#d6dce8 1px, transparent 1px); background-size: 22px 22px; overflow: hidden; }
.canvas-tools { position: absolute; right: 18px; top: 18px; z-index: 5; display: flex; gap: 10px; }
.zoom-group { display: flex; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.zoom-group button { border: 0; background: transparent; padding: 9px 12px; cursor: pointer; color: var(--ink); display: grid; place-items: center; }
.zoom-group button:hover { background: #f4f6fa; }
.zoom-group span { min-width: 56px; text-align: center; font-weight: 600; font-size: 13px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); padding: 9px 0; }
.canvas-tools .btn { box-shadow: var(--shadow); }
.status-bar { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 9px 16px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.status-bar .live { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--ink); }
.status-bar .live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.status-bar .live.on::before { background: var(--green); box-shadow: 0 0 0 4px rgba(22, 163, 74, .15); }
.status-bar span { display: inline-flex; align-items: center; gap: 6px; }
.status-bar svg { color: var(--ink-3); }

.props { background: #fff; border-left: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; }
.props-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.props-head h2 { margin: 0; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.props-head h2 small { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.props-head .spacer { flex: 1; }
.tabs { display: flex; border-bottom: 1px solid var(--line); margin: 16px 20px 0; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 10px 6px; font: inherit; font-weight: 600; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--blue); border-bottom-color: var(--blue); }
.props-body { padding: 4px 20px 24px; }
.props-body > label:first-child { margin-top: 16px; }
.props .section { margin-top: 18px; }
.props .section > h3 { font-size: 15px; margin-bottom: 8px; }
.props .help { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; background: #f7f9fc; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.props .problems { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 10px; padding: 10px 12px 10px 28px; font-size: 12.5px; margin: 0; }
.counter { text-align: right; font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.checklist { border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; max-height: 170px; overflow: auto; }
.checklist .check { margin: 8px 0; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1.5px dashed #cdd6e5; border-radius: 10px; padding: 14px; cursor: pointer; color: var(--blue); font-weight: 600; background: #fbfcfe; text-align: center; }
.dropzone:hover, .dropzone.over { border-color: var(--blue); background: var(--blue-soft); }
.dropzone small { color: var(--ink-3); font-weight: 400; font-size: 11.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: #f1f4f9; border-radius: 8px; padding: 4px 8px; }
.file-chip button { border: 0; background: none; cursor: pointer; color: var(--ink-3); padding: 0; display: grid; }
.link-row { display: grid; grid-template-columns: 1fr 1.25fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.link-row button { border: 0; background: none; cursor: pointer; color: var(--ink-2); display: grid; padding: 4px; }
.add-link { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--blue); cursor: pointer; }
.dur { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dur span { font-size: 11.5px; color: var(--ink-3); }
.perf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.perf div { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.perf b { display: block; font-size: 20px; }
.perf span { font-size: 12px; color: var(--ink-2); }

/* ---------------- Drawflow nodes */
.drawflow .drawflow-node { background: #fff; border: 1px solid var(--line); border-radius: 14px; width: 230px; padding: 0; box-shadow: 0 2px 10px rgba(15, 23, 42, .06); color: var(--ink); }
.drawflow .drawflow-node:hover { cursor: move; box-shadow: 0 6px 18px rgba(15, 23, 42, .1); }
.drawflow .drawflow-node.selected { background: #fff; border: 1.5px solid #8fb1ff; box-shadow: 0 0 0 4px rgba(26, 109, 255, .12), 0 6px 18px rgba(15, 23, 42, .1); color: var(--ink); }
.drawflow .drawflow-node .drawflow_content_node { width: 100%; }
.drawflow .drawflow-node .input, .drawflow .drawflow-node .output { width: 12px; height: 12px; border: 2px solid #fff; background: #3b82f6; box-shadow: 0 0 0 1px #bcd0f5; }
.drawflow .drawflow-node .output:hover, .drawflow .drawflow-node .input:hover { background: var(--blue-2); transform: scale(1.2); }
.drawflow .drawflow-node .inputs { left: -7px; } .drawflow .drawflow-node .outputs { right: -7px; }
.drawflow .connection .main-path { stroke: #4f8df7; stroke-width: 2px; }
.drawflow .connection .main-path:hover, .drawflow .connection .main-path.selected { stroke: var(--blue-2); stroke-width: 3px; }
.drawflow-delete { background: var(--red); border: 2px solid #fff; line-height: 26px; color: #fff; }
.drawflow .drawflow-node .drawflow-delete { right: -14px; top: -14px; }

.fnode-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.fnode-head .tile { width: 32px; height: 32px; border-radius: 9px; }
.fnode-head b { font-size: 15px; }
.fnode-head .count { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--blue); color: #fff; border-radius: 999px; padding: 2px 8px; display: none; }
.fnode-head .count.on { display: inline-block; }
.fnode-body { padding: 0 14px 12px; font-size: 12.5px; line-height: 1.45; }
.fnode-body .t { font-weight: 700; color: var(--ink); word-break: break-word; }
.fnode-body .s { color: var(--ink-2); margin-top: 2px; word-break: break-word; }
.fnode-body .warn { color: #c2410c; font-weight: 600; }
.fnode-foot { display: flex; gap: 12px; align-items: center; padding: 9px 14px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--ink-2); }
.fnode-foot:empty { display: none; }
.fnode-foot span { display: inline-flex; align-items: center; gap: 5px; }
.fnode-foot svg { color: var(--blue); }
.fnode-foot .ok { color: var(--green); font-weight: 600; }
.fnode-foot .ok svg { color: var(--green); }
.fnode-foot .sep { width: 1px; height: 14px; background: var(--line); }

.node-condition .outputs .output_1::after, .node-condition .outputs .output_2::after { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; color: #fff; pointer-events: none; }
.node-condition .outputs .output_1::after { content: "Yes"; background: #22c55e; }
.node-condition .outputs .output_2::after { content: "No"; background: #f43f5e; }
.node-condition .outputs .output_1 { background: #22c55e; box-shadow: 0 0 0 1px #bbf7d0; }
.node-condition .outputs .output_2 { background: #f43f5e; box-shadow: 0 0 0 1px #fecdd3; }
.node-box { border-left: 4px solid var(--boxc, #2f6bff) !important; }

/* ---------------- Journey */
.journey-canvas { height: 540px; position: relative; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background-color: #f7f9fc; background-image: radial-gradient(#d6dce8 1px, transparent 1px); background-size: 22px 22px; }
.journey-canvas .drawflow .drawflow-node { opacity: .4; filter: grayscale(.7); transition: all .3s; }
.journey-canvas .drawflow .drawflow-node.visited { opacity: 1; filter: none; border-color: #a7e3bf; }
.journey-canvas .drawflow .drawflow-node.current { opacity: 1; filter: none; border-color: var(--blue); animation: pulse 1.8s infinite; }
.journey-canvas .drawflow .connection .main-path { stroke: #d6dce8; }
.journey-canvas .drawflow .connection.taken .main-path { stroke: var(--green); stroke-width: 3.5px; stroke-dasharray: 8 6; animation: flowdash 1s linear infinite; }
.journey-canvas .drawflow .drawflow-node .input, .journey-canvas .drawflow .drawflow-node .output { cursor: default; }
@keyframes flowdash { to { stroke-dashoffset: -14; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 4px rgba(26, 109, 255, .18); } 50% { box-shadow: 0 0 0 10px rgba(26, 109, 255, .05); } }
.visit-no { position: absolute; top: -11px; left: -11px; width: 24px; height: 24px; border-radius: 50%; background: var(--green); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; z-index: 3; }

.chain { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.chain .flow-pill { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 14px; cursor: pointer; text-align: left; font: inherit; box-shadow: var(--shadow); }
.chain .flow-pill.sel { border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.chain .flow-pill b { display: block; font-size: 14px; margin-bottom: 4px; }
.chain .arrow { color: var(--ink-3); }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 16px 44px; }
.timeline .ti { position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2px solid var(--line); color: var(--ink-2); }
.timeline .ti.EmailSent { border-color: var(--purple); color: var(--purple); } .timeline .ti.Opened { border-color: var(--cyan); color: var(--cyan); }
.timeline .ti.Clicked { border-color: var(--green); color: var(--green); } .timeline .ti.Replied { border-color: var(--amber); color: var(--amber); background: #fffbeb; }
.timeline .ti.AddedToBox { border-color: var(--blue); color: var(--blue); } .timeline .ti.Error { border-color: var(--red); color: var(--red); }
.timeline .tt { font-weight: 600; padding-top: 5px; }
.timeline .tm { font-size: 11.5px; color: var(--ink-3); }
.timeline details { margin-top: 4px; font-size: 12px; }
.timeline details pre { white-space: pre-wrap; background: #f7f9fc; border-radius: 8px; padding: 8px; max-height: 240px; overflow: auto; }
.email-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 8px; background: #fff; }
.email-card .metrics2 { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.email-card .m { font-size: 11.5px; padding: 3px 8px; border-radius: 7px; background: #f1f5f9; color: var(--ink-3); display: inline-flex; align-items: center; gap: 4px; }
.email-card .m.on { background: var(--green-soft); color: var(--green); font-weight: 600; }

.modal-back { position: fixed; inset: 0; background: rgba(10, 20, 48, .5); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-back.open { display: flex; }
.modal { background: #fff; border-radius: 16px; width: min(780px, 100%); max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); }
.modal header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal .body { padding: 0; overflow: auto; flex: 1; }
.modal iframe { width: 100%; height: 70vh; border: 0; display: block; }

.menu { position: absolute; top: 56px; right: 150px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; display: none; min-width: 200px; }
.menu.open { display: block; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 12px; border-radius: 8px; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.menu button:hover, .menu a:hover { background: #f4f6fa; text-decoration: none; }

.unsub { max-width: 460px; margin: 10vh auto; text-align: center; }
.unsub img { width: 220px; margin-bottom: 18px; }
body.bare { display: block; }

/* Drawflow positions its own connection SVGs absolutely — keep our icons inline. */
.drawflow .drawflow-node svg.i { position: static; z-index: auto; overflow: visible; }

/* signed-in user at the bottom of the sidebar */
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 10px; border-top: 1px solid rgba(255, 255, 255, .09); }
.me .avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, #1a6dff, #0ea5e9); flex-shrink: 0; }
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who small { display: block; color: #8b97b8; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me form { margin: 0; }
.signout { border: 0; background: transparent; color: #8b97b8; padding: 8px; border-radius: 8px; cursor: pointer; display: grid; }
.signout:hover { background: rgba(255, 255, 255, .08); color: #fff; }

/* ---------------------------------------------------------------- Patch 002: contacts pager + import samples */
.pager { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: space-between; border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 14px; }
.pager .pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager .pg { min-width: 34px; height: 34px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); font-weight: 600; font-size: 13px; }
.pager a.pg:hover { background: #f7f9fc; border-color: #d7deea; text-decoration: none; }
.pager .pg.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.pager .pg.off { color: var(--ink-3); background: #fafbfe; }
.pager .pg.gap { border-color: transparent; background: transparent; min-width: 18px; padding: 0; color: var(--ink-3); }
.pager .per-page { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; font-size: 12.5px; color: var(--ink-2); }
.pager .per-page select { width: auto; padding: 6px 30px 6px 10px; }
.samples { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.cols-help { margin-top: 12px; }
.cols-help summary { cursor: pointer; color: var(--blue); font-weight: 600; }

/* ---------------------------------------------------------------- Patch 002: template gallery + easy template editor */
.tpl-card { display: flex; flex-direction: column; }
.tpl-thumb { position: relative; height: 340px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #f8fafc; }
.tpl-thumb iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; background: #fff; }
.tpl-actions { display: flex; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.tpl-actions .muted { margin-left: auto; }

.tpl-editor { display: grid; grid-template-columns: minmax(0, 470px) minmax(0, 1fr); gap: 18px; align-items: start; }
.tpl-editor > .card + .card { margin-top: 0; }
@media (max-width: 1100px) { .tpl-editor { grid-template-columns: 1fr; } }
.tpl-tabs { margin: 18px 0 4px; }
.tpl-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.tpl-sec { border-top: 1px solid var(--line-2); padding-top: 16px; margin-top: 18px; }
.tpl-sec:first-child { border-top: 0; margin-top: 8px; padding-top: 6px; }
.tpl-sec > h3 { font-size: 15px; margin-bottom: 10px; }
.tpl-sec > label:first-of-type { margin-top: 10px; }
.tpl-note { background: #fff7e6; border: 1px solid #fde3b0; border-radius: 12px; padding: 14px 16px; margin-top: 14px; }
.tpl-note p { margin: 6px 0 12px; color: var(--ink-2); }

.layout-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.layout-pick button { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 10px; font: inherit; cursor: pointer; color: var(--ink); }
.layout-pick button:hover { border-color: #c9d4e8; }
.layout-pick button.on { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.layout-pick small { color: var(--ink-2); font-size: 11.5px; }
.mini { display: flex; flex-direction: column; gap: 5px; width: 100%; height: 84px; border-radius: 8px; padding: 8px; margin-bottom: 6px; background: #f1f5f9; }
.mini i { display: block; height: 6px; border-radius: 3px; background: #cbd5e1; }
.mini i.s { width: 60%; }
.mini i.b { width: 42%; height: 12px; background: var(--blue); margin-top: 3px; }
.mini-branded { padding: 0 10px 8px; }
.mini-branded i.h { height: 18px; margin: 0 -10px 4px; border-radius: 8px 8px 0 0; background: #111827; }
.mini-branded i.f { margin-top: auto; height: 8px; background: #e2e8f0; }
.mini-plain { background: #fff; border: 1px solid var(--line); }

.choice { display: flex; gap: 8px; flex-wrap: wrap; }
.choice label { display: inline-flex; align-items: center; gap: 7px; margin: 0; padding: 7px 12px; border: 1px solid var(--line); border-radius: 9px; font-weight: 500; cursor: pointer; background: #fff; }
.choice label:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-2); }
.choice input { accent-color: var(--blue); margin: 0; }
.colors { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
label.color { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
label.color input[type=color] { width: 40px; height: 32px; cursor: pointer; }
.tpl-side input[type=range] { width: 100%; accent-color: var(--blue); }
.logo-thumb { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: repeating-conic-gradient(#f1f5f9 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.logo-thumb img { max-height: 56px; max-width: 220px; }
.logo-thumb button { margin-left: auto; }
.merge-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.merge-chips button { border: 1px dashed #b8c6e0; background: #f7f9fc; color: var(--blue-2); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.merge-chips button:hover { background: var(--blue-soft); border-style: solid; }
#htmlPane textarea { min-height: 520px; }

.tpl-preview { position: sticky; top: 18px; }
.tpl-preview-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.tpl-preview-head .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 10px; cursor: pointer; color: var(--ink-2); display: grid; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--blue-soft); color: var(--blue-2); }
.pv-wrap { background: #eef2f7; border-radius: 10px; padding: 0; display: flex; justify-content: center; transition: padding .2s; }
.pv-wrap iframe { width: 100%; height: calc(100vh - 230px); min-height: 560px; border: 1px solid var(--line); border-radius: 10px; background: #fff; transition: width .2s; }
.pv-wrap.mobile { padding: 14px 0; }
.pv-wrap.mobile iframe { width: 390px; border-radius: 18px; border: 8px solid #0f172a; }
.tpl-editor [hidden] { display: none !important; }

/* ================================================================ Patch 003 (UAT 14 Oct): fixes + responsive layout */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; font-weight: 500; }
.form-errors { background: var(--red-soft); border: 1px solid #f7c5c5; color: #b91c1c; border-radius: 10px; padding: 10px 14px; margin: 4px 0 12px; font-size: 13px; }
.form-errors ul { margin: 6px 0 0; padding-left: 18px; }
.warn-card { border-color: #fecaca !important; background: #fff5f5 !important; color: #7f1d1d; margin-bottom: 16px; line-height: 1.55; }
.warn-card code { background: #fff; border: 1px solid #fecaca; border-radius: 5px; padding: 1px 5px; }

/* Tables never spill out of their card (UAT DEF-010): they scroll inside it instead. */
.card { min-width: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card:has(> table.table) { overflow-x: auto; }
/* Row buttons may wrap onto two lines instead of pushing the table wider. */
.table td.actions { white-space: normal; }
.table td.actions > .btn, .table td.actions > form { margin: 2px 0 2px 4px; vertical-align: middle; }

/* Error / not-found page (UAT DEF-018) */
.error-page { max-width: 560px; margin: 8vh auto; text-align: center; padding: 34px 28px; }
.error-page .code { font-size: 56px; font-weight: 800; letter-spacing: -.04em; color: var(--blue); line-height: 1; margin-bottom: 10px; }
.error-page h1 { margin-bottom: 8px; }
.error-page p { margin: 0 0 22px; }

/* Contact details (UAT DEF-021) */
.contact-card { margin-bottom: 16px; }
.contact-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 22px; }
.contact-facts > div { min-width: 0; }
.contact-facts span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; margin-bottom: 3px; }
.contact-facts b { display: block; font-weight: 500; overflow-wrap: anywhere; }
.contact-facts .wide { grid-column: 1 / -1; }
.contact-boxes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.box-chip.removable { padding-right: 4px; }
.box-chip.removable button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; border-radius: 6px; opacity: .7; }
.box-chip.removable button:hover { opacity: 1; background: rgba(0, 0, 0, .07); }
.contact-actions { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.contact-actions .spacer { flex: 1; }
.edit-contact { flex: 1 1 100%; order: 3; }
.edit-contact > summary { list-style: none; display: inline-flex; }
.edit-contact > summary::-webkit-details-marker { display: none; }
.edit-contact[open] > summary { background: var(--blue-soft); border-color: #b9cdf6; }
.edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; margin-top: 6px; max-width: 760px; }
.edit-grid .wide { grid-column: 1 / -1; }
.edit-grid .wide .btn { margin-top: 14px; }
.add-to-box { min-width: 300px; }

/* Condition steps: Yes / No handles further apart and easier to grab (UAT DEF-027). */
.drawflow .drawflow-node.node-condition .output { width: 15px; height: 15px; }
.drawflow .drawflow-node.node-condition .outputs .output_2 { margin-top: 22px; }

/* ---------------------------------------------------------------- mobile top bar (hidden on desktop) */
.mobile-bar, .nav-scrim { display: none; }

/* ---------------------------------------------------------------- builder on laptops (UAT DEF-027) */
@media (max-width: 1600px) {
  /* The builder needs the width: the app menu shrinks to icons there (names show on hover). */
  body.app-shell.full-bleed .sidebar { width: 72px; padding: 22px 10px; }
  body.app-shell.full-bleed .brand { width: 46px; overflow: hidden; padding: 0 0 22px 3px; }
  body.app-shell.full-bleed .brand img { width: 196px; max-width: none; }
  body.app-shell.full-bleed .sidebar nav a { justify-content: center; padding: 12px 0; gap: 0; }
  body.app-shell.full-bleed .sidebar nav a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  body.app-shell.full-bleed .me { flex-direction: column; padding: 12px 0; }
  body.app-shell.full-bleed .me .who { display: none; }
}
@media (max-width: 1440px) {
  body.app-shell .builder { grid-template-columns: 208px minmax(0, 1fr) 330px; }
  body.app-shell .palette { padding: 16px 12px; }
  body.app-shell .palette-item { padding: 10px; gap: 10px; }
  body.app-shell .palette-item .tile { width: 34px; height: 34px; }
  body.app-shell .metrics { gap: 18px; }
}
@media (max-width: 1200px) {
  body.app-shell .builder-top .metrics { display: none; }
  body.app-shell .builder { grid-template-columns: 184px minmax(0, 1fr) 300px; }
  body.app-shell .palette-item .drag, body.app-shell .palette-item small { display: none; }
}

/* ---------------------------------------------------------------- tablets and phones (UAT DEF-011) */
@media (max-width: 900px) {
  body.app-shell { display: block; }
  body.app-shell .mobile-bar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 90; height: 56px; padding: 0 12px; background: linear-gradient(90deg, #0f1c42, #0a1431); box-shadow: 0 2px 10px rgba(10, 20, 48, .25); }
  body.app-shell .nav-toggle { border: 0; background: rgba(255, 255, 255, .08); color: #fff; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
  body.app-shell .nav-toggle:focus-visible { outline: 3px solid #8fb1ff; }
  body.app-shell .mobile-brand img { height: 30px; width: auto; display: block; }
  body.app-shell .sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: auto; width: 270px; max-width: 85vw; z-index: 120; transform: translateX(-105%); transition: transform .22s ease; box-shadow: none; }
  body.app-shell.nav-open .sidebar { transform: none; box-shadow: 10px 0 40px rgba(10, 20, 48, .35); }
  body.app-shell.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 110; background: rgba(10, 20, 48, .45); }
  body.app-shell.nav-open { overflow: hidden; }
  /* the full menu (names included) inside the slide-out drawer, also on the builder */
  body.app-shell.full-bleed .sidebar { width: 270px; padding: 22px 16px; }
  body.app-shell.full-bleed .brand { width: auto; padding: 0 6px 26px; }
  body.app-shell.full-bleed .sidebar nav a { justify-content: flex-start; padding: 12px 14px; gap: 14px; }
  body.app-shell.full-bleed .sidebar nav a span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  body.app-shell.full-bleed .me { flex-direction: row; padding: 12px 10px; }
  body.app-shell.full-bleed .me .who { display: block; }
  body.app-shell .main { padding: 20px 16px 40px; }
  body.app-shell .page-head { margin-bottom: 16px; }
  body.app-shell .page-head > form, body.app-shell .page-head > .row, body.app-shell .page-head > div:last-child:not(:first-child) { min-width: 0 !important; width: 100%; }
  body.app-shell .page-head h1 { font-size: 22px; }
  body.app-shell .card { padding: 16px; }
  body.app-shell .settings-list { grid-template-columns: minmax(0, 1fr); }
  body.app-shell .settings-list > div:nth-child(odd) { padding-bottom: 0; border-bottom: 0; font-size: 12px; }
  body.app-shell .add-to-box { min-width: 0; }
  body.app-shell .edit-grid { grid-template-columns: minmax(0, 1fr); }
  body.app-shell .pager { justify-content: center; }
  body.app-shell .modal-back { padding: 8px; }
  body.app-shell .modal iframe { height: 75vh; }
  .unsub { margin: 6vh auto; width: calc(100% - 32px); }
  body.app-shell.full-bleed .flash { top: 64px; width: calc(100% - 24px); }
  /* Flow builder: steps strip on top, canvas, then the settings panel below. */
  body.app-shell .builder { display: flex; flex-direction: column; height: auto; min-height: calc(100vh - 56px); }
  body.app-shell .builder-top { flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; min-height: 0; }
  body.app-shell .builder-top .spacer { display: none; }
  body.app-shell .crumbs { flex: 1 1 100%; flex-wrap: wrap; }
  body.app-shell .crumbs .title { font-size: 16px; }
  body.app-shell .menu { right: 12px; top: auto; margin-top: 44px; }
  body.app-shell .palette { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  body.app-shell .palette h3, body.app-shell .palette .hint, body.app-shell .palette .input-icon { display: none; }
  body.app-shell #paletteList { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
  body.app-shell .palette-item { flex: 0 0 auto; margin: 0; padding: 8px 12px 8px 8px; }
  body.app-shell .palette-item .grip { display: none; }
  body.app-shell #canvas { height: 62vh; min-height: 360px; }
  body.app-shell .canvas-tools { right: 10px; top: 10px; }
  body.app-shell .status-bar { left: 10px; right: 10px; transform: none; bottom: 10px; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; }
  body.app-shell .props { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  body.app-shell .tabs { margin: 12px 16px 0; }
  body.app-shell .props-body { padding: 4px 16px 24px; }
  body.app-shell .pv-wrap.mobile iframe { width: 100%; max-width: 390px; }
  body.app-shell .journey-canvas { height: 420px; }
}
@media (max-width: 560px) {
  body.app-shell .main { padding: 16px 12px 36px; }
  body.app-shell .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  body.app-shell .stat { padding: 12px; gap: 10px; }
  body.app-shell .stat .si { width: 34px; height: 34px; }
  body.app-shell .stat b { font-size: 18px; }
  body.app-shell .row > * { min-width: 0; flex-basis: 100%; }
  body.app-shell .row > .btn, body.app-shell .row > .shrink { flex-basis: auto; }
  body.app-shell .layout-pick { grid-template-columns: minmax(0, 1fr); }
  body.app-shell .tpl-preview-head { gap: 8px; }
  body.app-shell .builder-top .btn { padding: 8px 12px; }
  body.app-shell .error-page { margin: 4vh auto; padding: 26px 18px; }
}
