/* Postlane — airmail-inspired, quiet UI */
:root {
  --paper: #F6F7F9; --surface: #FFFFFF; --ink: #18212F; --ink-2: #3A4352; --muted: #6B7383; --line: #E3E6EB; --line-2: #EEF0F3;
  --blue: #2445C2; --blue-dark: #1A3399; --blue-soft: #EAEEFC; --red: #D2384B; --red-soft: #FBEAEC;
  --green: #1F8A5B; --green-soft: #E5F4EC; --amber: #B7791F; --amber-soft: #FBF2E2;
  --airmail: repeating-linear-gradient(135deg, var(--red) 0 9px, #fff 9px 15px, var(--blue) 15px 24px, #fff 24px 30px);
  --r: 10px; --r-sm: 7px;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--paper); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -.01em; margin: 0; line-height: 1.2; }
h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0 0 10px; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--line-2); padding: 2px 6px; border-radius: 5px; }
small { font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .break { word-break: break-all; }
.warn-text { color: var(--amber); } .ok-text { color: var(--green); } .danger-text { color: var(--red) !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 0 12px 16px; }
.airmail { height: 5px; background: var(--airmail); margin: 0 -12px 18px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 19px var(--display); color: var(--ink); padding: 4px 10px 18px; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--ink); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linejoin: round; }
.brand.big { justify-content: center; font-size: 22px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; }
.sidebar nav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sidebar nav a:hover { background: var(--line-2); text-decoration: none; }
.sidebar nav a.on { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.me { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 14px; min-width: 0; }
.me small { display: block; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.muted-link { color: var(--muted); font-size: 13px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 22px 32px 14px; }
.topbar h1 { font-size: 30px; letter-spacing: -.025em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 8px 32px 48px; }
.icon-btn.menu-toggle { display: none; }
.scrim { display: none; }
.flash { margin: 0 32px 12px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 14px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { border-color: #C9CED6; background: #FAFBFC; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { color: var(--red); border-color: #F0C5CB; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ai::before { content: '✦'; font-size: 12px; color: var(--blue); }
.btn.primary.ai::before { color: #fff; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.big { height: 46px; padding: 0 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 17px; cursor: pointer; text-decoration: none !important; }
.icon-btn:hover { background: var(--line-2); }
.icon-btn.sm { width: 28px; height: 28px; font-size: 14px; }
.icon-btn.disabled { opacity: .35; cursor: default; }
form.inline { display: inline; }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
label small, .label small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: 400 14.5px var(--font); color: var(--ink); background: var(--surface); border: 1px solid #D4D8DF; border-radius: var(--r-sm); padding: 9px 12px; width: 100%; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; accent-color: var(--blue); flex: none; margin: 0; }
input[type=color] { width: 36px; padding: 2px; min-height: 34px; height: 34px; }
textarea { resize: vertical; line-height: 1.5; }
textarea.code { font: 12.5px/1.5 ui-monospace, Menlo, monospace; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; }
label.check input { margin-top: 3px; }
.consent { background: var(--amber-soft); padding: 12px 14px; border-radius: var(--r-sm); color: #6B4A12; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { font-weight: 700; font-size: 13.5px; padding: 0; margin-bottom: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-gap.tight { gap: 6px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 140px; }
.inline-label { flex-direction: row; align-items: center; gap: 8px; }
.num-sm { width: 80px !important; flex: none !important; min-width: 0 !important; }
.field-with-action { display: flex; gap: 10px; align-items: flex-start; }
.field-with-action label { flex: 1; }
.field-with-action .btn { margin-top: 26px; }
.narrow { max-width: 760px; }
.lede { color: var(--ink-2); max-width: 70ch; margin-bottom: 18px; }

/* ---------- Panels, alerts ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel h2 + p { margin-top: 6px; }
.alert { padding: 11px 14px; border-radius: var(--r-sm); font-size: 14px; border: 1px solid; }
.alert.success { background: var(--green-soft); border-color: #C3E5D3; color: #155E3E; }
.alert.error { background: var(--red-soft); border-color: #F0C5CB; color: #922536; }
.alert.info { background: var(--blue-soft); border-color: #CBD4F6; color: #1D3596; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.empty { text-align: center; padding: 56px 24px; background: var(--surface); border: 1px dashed #CFD4DC; border-radius: var(--r); }
.empty h2 { font-size: 22px; margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 52ch; margin: 0 auto 18px; }
.empty .row-gap { justify-content: center; }
.empty.small { padding: 28px 16px; border-style: dashed; }
.empty.small p { margin-bottom: 12px; }

/* ---------- Badges, tags, avatars ---------- */
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.b-sent, .b-subscribed, .b-active, .b-completed { background: var(--green-soft); color: #176B47; }
.b-sending, .b-queued { background: var(--blue-soft); color: var(--blue); }
.b-scheduled { background: #EFE9FB; color: #5B37A6; }
.b-paused { background: var(--amber-soft); color: #8A5A14; }
.b-cancelled, .b-bounced, .b-complained { background: var(--red-soft); color: #A62B3D; }
.b-unsubscribed, .b-exited { background: #EEF0F3; color: #565E6C; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; margin: 2px 4px 2px 0; border-radius: 5px; font-size: 12.5px; font-weight: 600;
  color: var(--c, var(--blue)); background: color-mix(in srgb, var(--c, var(--blue)) 11%, white); }
.tag.removable button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 2px; font-size: 14px; opacity: .7; }
.tag-cloud { display: flex; flex-wrap: wrap; margin-bottom: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 60px; height: 60px; font-size: 20px; }
.person { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.person b { font-weight: 600; display: block; }
.person small { color: var(--muted); }

/* ---------- Tables, lists ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.list-area > form > .table, .list-area > .table { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FBFBFC; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FBFBFD; }
.table.compact td { padding: 10px 6px; }
.table .chk { width: 36px; }
.table .num { text-align: right; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; }

/* ---------- Filters + toolbar ---------- */
.with-filters { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; align-items: start; }
.filters { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; }
.filters h3 { font-size: 15px; margin: 18px 0 8px; }
.filters h3:first-child { margin-top: 0; }
.filter { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-size: 14.5px; }
.filter svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.filter span:last-child { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.filter:hover { background: var(--line-2); text-decoration: none; }
.filter.on { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search { flex: 1; min-width: 220px; position: relative; display: block; }
.search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search input { padding-left: 40px; height: 42px; }
.sort { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; }
.sort select { width: 150px; height: 42px; }
.pager { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); margin-left: auto; }
.pager b { color: var(--ink); }
.bulkbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 10px; background: var(--ink); color: #fff; border-radius: var(--r); }
.bulkbar b { margin-right: 6px; }
.bulkbar input.sm { width: 160px; height: 32px; min-height: 0; }

/* ---------- Campaign list ---------- */
.campaign-list, .auto-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.campaign-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 150px repeat(3, 92px) 40px; gap: 18px; align-items: center; padding: 18px 8px; border-bottom: 1px solid var(--line); }
.campaign-row:first-child { border-top: 1px solid var(--line); }
.auto-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px repeat(4, 90px) 40px; gap: 16px; align-items: center; margin-bottom: 10px; }
.thumb { position: relative; display: block; width: 76px; height: 64px; overflow: hidden; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.thumb::before { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: var(--airmail); background-size: 30px 30px; z-index: 1; }
.thumb iframe { width: 600px; height: 520px; border: 0; transform: scale(.127); transform-origin: 0 0; pointer-events: none; }
.thumb.tall { width: 100%; height: 220px; }
.thumb.tall iframe { transform: scale(.4); width: 250%; height: 250%; }
.c-name { font-size: 17px; font-weight: 600; color: var(--ink); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-sub { color: var(--muted); font-size: 14px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.c-sub b { color: var(--ink-2); font-weight: 600; }
.c-status { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.when { font-size: 13px; color: var(--muted); border-bottom: 1px dashed #C9CED6; cursor: help; }
.c-stat { text-align: center; }
.c-stat b { display: block; font: 600 17px var(--display); }
.c-stat span { font-size: 12.5px; color: var(--muted); }
.progress { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; margin: 8px 0 12px; }
.progress span { display: block; height: 100%; background: var(--blue); border-radius: 99px; transition: width .4s; }
.progress.thin { height: 4px; width: 100px; margin: 4px 0 0; }

/* ---------- Menus & modals ---------- */
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 40px; z-index: 30; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 12px 32px -8px rgba(24, 33, 47, .22); padding: 6px; display: none; }
.menu.open .menu-pop { display: block; }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 6px; font: 500 14.5px var(--font); color: var(--ink); cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--line-2); text-decoration: none; }
.modal { border: 0; border-radius: 14px; padding: 22px 24px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 24px 64px -12px rgba(24, 33, 47, .35); color: var(--ink); }
.modal.wide { width: min(900px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(24, 33, 47, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Stepper / wizard ---------- */
.stepper { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 18px; counter-reset: s; flex-wrap: wrap; }
.stepper li { counter-increment: s; display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 8px; border-radius: 99px; color: var(--muted); font-weight: 600; font-size: 14px; background: var(--surface); border: 1px solid var(--line); }
.stepper li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--line-2); font-size: 12.5px; }
.stepper li.on { color: var(--ink); border-color: var(--ink); }
.stepper li.on::before { background: var(--ink); color: #fff; }
.stepper li.done::before { content: '✓'; background: var(--green-soft); color: var(--green); }
.stepper.clickable li { cursor: pointer; }
.step-nav { display: flex; justify-content: space-between; margin-top: 8px; }
.step.panel { max-width: 860px; }
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice { flex-direction: row; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; font-weight: 400; }
.choice:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.choice input { margin-top: 3px; }
.choice b { display: block; color: var(--ink); font-size: 15px; }
.choice small { color: var(--muted); }
.choice em { display: block; font-style: normal; font-size: 12.5px; color: var(--blue); font-weight: 600; margin-top: 4px; }
.pick-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 99px; font-weight: 500; cursor: pointer; color: var(--ink); }
.pick small { color: var(--muted); }
.pick:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.exclude summary { cursor: pointer; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; }
.count-bar { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--paper); border-radius: var(--r-sm); }
.count-bar b { font: 700 22px var(--display); }
.inbox-preview { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); }
.inbox-preview div { display: flex; flex-direction: column; min-width: 0; }
.inbox-preview b, .inbox-preview span, .inbox-preview small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-preview span { font-weight: 600; color: var(--ink-2); }
.inbox-preview small { color: var(--muted); }
.suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: -6px; }
.suggestions button { text-align: left; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); font: 500 14px var(--font); cursor: pointer; color: var(--ink); }
.suggestions button:hover { border-color: var(--blue); background: var(--blue-soft); }
.review-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.review-list li { display: flex; gap: 10px; align-items: flex-start; }
.review-list li::before { content: '✓'; flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; background: var(--green-soft); color: var(--green); font-weight: 700; }
.review-list li.bad::before { content: '!'; background: var(--red-soft); color: var(--red); }
.review-list li a { margin-left: auto; font-size: 13px; }
.test-send { display: flex; gap: 10px; align-items: flex-end; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.test-send label { flex: 1; }
.send-box { display: flex; flex-direction: column; gap: 14px; }
.preview-panel iframe { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }

/* ---------- Editor ---------- */
.editor-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px; position: sticky; top: 0; z-index: 5; }
.tools { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.tools.right { margin-left: auto; gap: 8px; }
.tools > button:not(.btn) { height: 32px; min-width: 32px; padding: 0 10px; border: 1px solid transparent; background: none; border-radius: 6px; cursor: pointer; font: 600 13.5px var(--font); color: var(--ink-2); }
.tools > button:not(.btn):hover { background: var(--line-2); border-color: var(--line); }
.tools select { width: auto; height: 32px; min-height: 0; padding: 0 8px; font-size: 13.5px; }
.seg-toggle { display: inline-flex; background: var(--line-2); padding: 3px; border-radius: 8px; gap: 2px; }
.seg-toggle button { border: 0; background: none; padding: 6px 12px; border-radius: 6px; font: 600 13px var(--font); color: var(--muted); cursor: pointer; }
.seg-toggle button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg-toggle.full { display: flex; } .seg-toggle.full button { flex: 1; }
.editor-wrap { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.canvas { flex: 1; min-width: 0; position: relative; background: #E9ECF0; border-radius: var(--r); padding: 18px; display: flex; justify-content: center; }
.canvas iframe { width: 100%; max-width: 100%; height: 72vh; min-height: 520px; border: 0; background: #fff; border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); transition: max-width .2s; }
.canvas.mobile iframe { max-width: 390px; }
.canvas textarea { width: 100%; height: 72vh; min-height: 520px; font: 12.5px/1.55 ui-monospace, Menlo, monospace; background: #fff; }
.canvas-empty { position: absolute; inset: 18px; background: #fff; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.canvas-empty p { color: var(--muted); }
.ai-panel { width: 360px; flex: none; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
.ai-status { padding: 12px; border-radius: var(--r-sm); background: var(--blue-soft); color: var(--blue); font-size: 14px; }
.ai-status.error { background: var(--red-soft); color: #922536; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font: 500 13.5px var(--font); color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: #C9CED6; text-decoration: none; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; max-height: 70vh; overflow-y: auto; padding: 2px; }
.template-grid.page { max-height: none; }
.template-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); cursor: pointer; font: inherit; color: var(--ink); }
button.template-card:hover { border-color: var(--blue); }
.template-card small { color: var(--muted); }
.template-card .row-gap { margin-top: 8px; }

/* ---------- Dashboard & report ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 20px; }
.kpis.inline { grid-template-columns: repeat(4, 1fr); margin: 14px 0; }
.kpi { background: var(--surface); padding: 18px 20px; display: flex; flex-direction: column; }
.kpi b { font: 700 28px var(--display); letter-spacing: -.02em; }
.kpi span { font-weight: 600; font-size: 14px; }
.kpi small { color: var(--muted); }
.setup { margin-bottom: 20px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.checklist small { display: block; color: var(--muted); }
.checklist a { font-weight: 600; }
.checklist li.done a { color: var(--muted); text-decoration: line-through; }
.tick { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; }
.done .tick { background: var(--green); border-color: var(--green); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 64px auto 1fr; gap: 10px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.timeline li:last-child { border: 0; }
.timeline time { color: var(--muted); font-size: 13px; font-style: italic; padding-top: 4px; }
.ev-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); margin-top: 6px; }
.ev-open .ev-dot { background: var(--blue); } .ev-click .ev-dot { background: var(--green); } .ev-bounce .ev-dot, .ev-complaint .ev-dot { background: var(--red); } .ev-unsubscribe .ev-dot { background: var(--amber); }
.report-meta { color: var(--ink-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.report-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.rings { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; align-items: center; padding: 26px 20px; }
.big-stat { text-align: center; display: flex; flex-direction: column; }
.big-stat b { font: 700 40px var(--display); letter-spacing: -.03em; }
.big-stat span { color: var(--blue); font-weight: 600; }
.ring-stat { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ring { --p: 0; --rc: var(--blue); width: 116px; height: 116px; border-radius: 50%; background: conic-gradient(var(--rc) calc(var(--p) * 1%), var(--line-2) 0); display: grid; place-items: center; }
.ring > div { width: 92px; height: 92px; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring b { font: 600 20px var(--display); } .ring span { font-size: 13px; color: var(--muted); }
.ring-label { color: var(--blue); font-weight: 600; font-size: 14.5px; }
.chart-wrap { position: relative; }
.chart-wrap canvas { width: 100%; display: block; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.lg-open::before { background: var(--blue); } .lg-click::before { background: var(--green); }
.activity-panel { background: #FBFBFC; }
.activity-panel h2 { margin-bottom: 10px; }
.link-stats { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.link-stats span { display: block; color: var(--muted); font-size: 13px; }
.sending-box { margin-bottom: 20px; border-color: #CBD4F6; }
.profile { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; }
.profile h2 { font-size: 22px; }
.mini-stats { display: flex; gap: 20px; text-align: center; }
.mini-stats b { display: block; font: 700 20px var(--display); }
.mini-stats span { font-size: 12.5px; color: var(--muted); }
.danger-zone { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.custom-fields { display: flex; flex-direction: column; gap: 8px; }
.custom-fields .label { font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.tag-edit { display: flex; gap: 8px; align-items: center; }
.tag-edit input[name=name] { min-height: 34px; padding: 5px 10px; }

/* ---------- Segments ---------- */
.match-line { display: flex; align-items: center; gap: 8px; font-weight: 500; flex-wrap: wrap; }
.match-line select { width: auto; }
.rules { display: flex; flex-direction: column; gap: 8px; }
.rule { display: grid; grid-template-columns: 170px 180px 1fr 36px; gap: 8px; align-items: center; padding: 10px; background: var(--paper); border-radius: var(--r-sm); }
.rule .join { grid-column: 1 / -1; font-size: 12.5px; font-weight: 700; color: var(--muted); }

/* ---------- Automations ---------- */
.auto-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.flow { display: flex; flex-direction: column; align-items: center; }
.flow-node { width: min(520px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; position: relative; }
.flow-node.trigger { border: 0; color: #fff; background: var(--ink); }
.flow-node.trigger::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--airmail); background-size: 30px 30px; border-radius: var(--r) var(--r) 0 0; }
.flow-node.trigger .node-kind, .flow-node.trigger small { color: #B9C0CC; }
.flow-node.trigger b, .flow-node.trigger small { display: block; }
.flow-node.email { border-left: 4px solid var(--blue); }
.flow-node.wait { border-left: 4px solid var(--amber); width: min(380px, 100%); }
.flow-node.add_tag, .flow-node.remove_tag { border-left: 4px solid var(--green); width: min(380px, 100%); }
.flow-node.end { width: auto; padding: 8px 20px; border-radius: 99px; color: var(--muted); background: var(--line-2); border: 0; }
.node-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.node-kind { font-size: 12.5px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 4px; }
.node-tools { display: flex; gap: 4px; }
.node-title { font-weight: 600; font-size: 16px; color: var(--ink); display: block; margin-bottom: 6px; }
.node-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); align-items: center; }
.add-step { position: relative; display: flex; flex-direction: column; align-items: center; padding: 6px 0; }
.add-step::before, .add-step::after { content: ''; width: 2px; height: 10px; background: #CFD4DC; }
.add-step summary { list-style: none; width: 28px; height: 28px; border-radius: 50%; border: 1px solid #CFD4DC; background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--muted); font-weight: 700; }
.add-step summary::-webkit-details-marker { display: none; }
.add-step summary:hover { border-color: var(--blue); color: var(--blue); }
.add-menu { position: absolute; z-index: 10; left: 50%; translate: -50% 0; top: 44px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 32px -8px rgba(24, 33, 47, .22); padding: 6px; display: flex; flex-direction: column; min-width: 170px; }
.add-menu button { border: 0; background: none; padding: 8px 12px; text-align: left; font: 500 14px var(--font); border-radius: 6px; cursor: pointer; }
.add-menu button:hover { background: var(--line-2); }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }

/* ---------- Settings ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-color: var(--ink); }
.provider-card.off { opacity: .6; }
.provider-card .inline-form { margin-bottom: 10px; }
code.copy { display: block; padding: 10px 12px; word-break: break-all; cursor: copy; border: 1px dashed #CFD4DC; background: var(--paper); }
.webhook summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.webhook p { margin-top: 8px; }
.form-preview { padding: 18px; background: var(--paper); border-radius: var(--r-sm); }

/* ---------- Import ---------- */
.dropzone { border: 2px dashed #CFD4DC; border-radius: var(--r); padding: 32px 18px; text-align: center; align-items: center; cursor: pointer; font-weight: 500; position: relative; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone.drag, .dropzone:hover { border-color: var(--blue); background: var(--blue-soft); }
.dropzone b { color: var(--blue); font-size: 16px; }
.map-table select { min-width: 200px; }
.steps-list { line-height: 1.8; padding-left: 20px; }

/* ---------- Auth ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 28px 28px; overflow: hidden; }
.auth-card.wide { width: min(760px, 100%); }
.auth-card .airmail { margin: 0 -28px 24px; height: 6px; }
.auth-title { font-size: 26px; margin: 14px 0 18px; text-align: center; }
.form-grid { display: grid; gap: 22px; }
.form-grid fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid legend { grid-column: 1 / -1; font: 700 16px var(--display); }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; translate: -50% 20px; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 99px; font-weight: 500; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; translate: -50% 0; }
#toast.error { background: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .campaign-row { grid-template-columns: 64px minmax(0, 1fr) 130px repeat(3, 76px) 40px; gap: 12px; }
  .thumb { width: 64px; } .thumb iframe { transform: scale(.107); }
  .rings { grid-template-columns: repeat(3, 1fr); row-gap: 24px; }
  .grid-side, .report-grid { grid-template-columns: 1fr; }
  .ai-panel { width: 320px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(24, 33, 47, .4); z-index: 40; }
  .icon-btn.menu-toggle { display: inline-grid; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .progress.thin { width: 100%; max-width: 100px; }
  .topbar { padding: 16px; flex-wrap: wrap; } .topbar h1 { font-size: 24px; }
  .content { padding: 4px 16px 40px; } .flash { margin: 0 16px 12px; }
  .with-filters { grid-template-columns: 1fr; gap: 12px; }
  .filters { position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .filters h3 { display: none; } .filters select { width: auto; }
  .filter span:last-child { margin-left: 4px; }
  .campaign-row { grid-template-columns: 56px minmax(0, 1fr) 40px; row-gap: 8px; }
  .campaign-row .thumb { width: 56px; height: 52px; grid-row: span 2; }
  .campaign-row .c-status { grid-column: 2; flex-direction: row; justify-content: flex-start; }
  .campaign-row .c-stat { display: none; }
  .campaign-row .menu { grid-row: 1; grid-column: 3; }
  .auto-row { grid-template-columns: 1fr auto 40px; } .auto-row .c-stat { display: none; }
  .grid-2, .two, .three, .choice-cards, .kpis, .kpis.inline, .form-grid fieldset { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .rings { grid-template-columns: 1fr 1fr; }
  .editor-wrap { flex-direction: column; } .ai-panel { width: 100%; position: static; max-height: none; }
  .rule { grid-template-columns: 1fr 1fr; } .rule > :nth-child(4) { grid-column: 1; }
  .profile { grid-template-columns: auto 1fr; } .mini-stats { grid-column: 1 / -1; }
  .pager { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
