:root {
  --navy: #16304f; --navy-2: #1f416a; --ink: #1b2333; --muted: #667085; --line: #e4e1da; --line-2: #efece6;
  --bg: #f6f4ef; --card: #ffffff; --brass: #b4873a; --brass-soft: #f5ecdc;
  --hot: #d9534f; --hot-soft: #fdecea; --warm: #d98a1f; --warm-soft: #fdf3e2; --cold: #8a94a6;
  --ok: #2f855a; --ok-soft: #e6f4ec; --info-soft: #e8eef6;
  --r: 12px; --shadow: 0 1px 2px rgba(16,24,40,.04), 0 2px 10px rgba(16,24,40,.05);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Fraunces', Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--navy-2); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font: 600 26px/1.2 var(--serif); letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 14px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* shell */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #dfe6f0; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font: 600 19px var(--serif); text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: #c9d4e3; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: rgba(255,255,255,.11); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.side .foot { margin-top: auto; font-size: 12px; color: #9fb0c6; padding: 8px; }
.main { padding: 28px 32px 60px; max-width: 1240px; width: 100%; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.bottomnav { display: none; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.tile { padding: 14px 16px; }
.tile .n { font: 600 26px/1.1 var(--serif); }
.tile .l { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 14px; font-weight: 550; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; min-height: 38px; }
.btn:hover { border-color: #cfcabf; background: #fcfbf8; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.brass { background: var(--brass); border-color: var(--brass); color: #fff; }
.btn.danger { color: var(--hot); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; min-height: 30px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
label.f { display: block; font-size: 13px; font-weight: 600; color: #3b4456; }
label.f > span.h { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.in, select.in, textarea.in { width: 100%; border: 1px solid #d8d4cb; border-radius: 9px; padding: 9px 11px; background: #fff; margin-top: 5px; outline: none; }
.in:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(31,65,106,.12); }
textarea.in { min-height: 120px; resize: vertical; line-height: 1.5; }
.form { display: grid; gap: 12px; }
.form.cols { grid-template-columns: 1fr 1fr; }
.form .full { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; }
.search { position: relative; }
.search input { padding-left: 34px; margin-top: 0; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--muted); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: var(--line-2); color: #4a5366; white-space: nowrap; }
.pill.hot { background: var(--hot-soft); color: #b03a36; } .pill.warm { background: var(--warm-soft); color: #9a5c07; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.info { background: var(--info-soft); color: var(--navy-2); }
.pill.brass { background: var(--brass-soft); color: #8a6420; } .pill.bad { background: #f3e8e8; color: #8b3a3a; }
.tag { display: inline-block; background: #f1efe9; border-radius: 6px; padding: 1px 7px; font-size: 12px; color: #5b6273; margin: 2px 4px 2px 0; }
.score { display: inline-grid; place-items: center; min-width: 30px; height: 24px; border-radius: 7px; font-weight: 700; font-size: 12.5px; padding: 0 6px; background: var(--line-2); color: var(--cold); }
.score.hot { background: var(--hot); color: #fff; } .score.warm { background: var(--warm); color: #fff; }

/* banners */
.banner { border-radius: 10px; padding: 11px 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; font-size: 14px; }
.banner.warn { background: var(--warm-soft); border: 1px solid #f1d6a8; }
.banner.info { background: var(--info-soft); border: 1px solid #cdd9ea; }
.banner.bad { background: var(--hot-soft); border: 1px solid #f3c6c3; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: center; padding: 11px 16px; border-top: 1px solid var(--line-2); }
.list > li:first-child { border-top: none; }
.list > li.click { cursor: pointer; } .list > li.click:hover { background: #faf9f6; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.taskbox { width: 20px; height: 20px; border-radius: 6px; border: 2px solid #c4beb2; background: #fff; cursor: pointer; flex: none; display: grid; place-items: center; padding: 0; }
.taskbox.done { background: var(--ok); border-color: var(--ok); }
.taskbox.done::after { content: ''; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.due-late { color: var(--hot); font-weight: 600; }

/* table */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fbfaf7; position: sticky; top: 0; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #faf9f6; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow: auto; max-height: calc(100vh - 230px); }

/* contact page */
.c-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.avatar { width: 52px; height: 52px; border-radius: 14px; background: var(--brass-soft); color: #8a6420; display: grid; place-items: center; font: 600 20px var(--serif); flex: none; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.timeline li:first-child { border-top: none; }
.ti { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--line-2); color: var(--muted); }
.ti svg { width: 15px; height: 15px; }
.ti.email_sent { background: var(--info-soft); color: var(--navy-2); }
.ti.email_open, .ti.email_click, .ti.visit { background: var(--warm-soft); color: var(--warm); }
.ti.reply, .ti.appointment { background: var(--ok-soft); color: var(--ok); }
.ti.unsubscribe, .ti.bounced, .ti.complained, .ti.email_failed { background: var(--hot-soft); color: var(--hot); }
.ti.note { background: var(--brass-soft); color: var(--brass); }
.tl-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.drip-bar { height: 6px; border-radius: 4px; background: var(--line-2); overflow: hidden; margin: 8px 0; }
.drip-bar > i { display: block; height: 100%; background: var(--brass); }

/* pipeline */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; min-height: 60vh; }
.col { background: #efece5; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; min-height: 200px; }
.col.drop { outline: 2px dashed var(--brass); }
.col-h { display: flex; justify-content: space-between; font-weight: 650; font-size: 13.5px; padding: 2px 4px 10px; }
.col-b { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 70vh; }
.kcard { background: #fff; border-radius: 10px; padding: 10px 11px; box-shadow: var(--shadow); cursor: grab; border: 1px solid var(--line); font-size: 13.5px; }
.kcard:active { cursor: grabbing; }
.kcard .nm { font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }

/* steps editor */
.step { display: grid; grid-template-columns: 90px 110px 1fr 36px; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line-2); }
.step .in { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fbfaf7; border-radius: 7px; padding: 3px 8px; font-size: 12px; cursor: pointer; font-family: ui-monospace, Menlo, monospace; }
.chip:hover { border-color: var(--brass); }
.preview { border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.preview .subj { padding: 10px 14px; border-bottom: 1px solid var(--line-2); font-weight: 600; }
.preview iframe { width: 100%; height: 420px; border: 0; display: block; }
.warnline { color: #9a5c07; font-size: 13px; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(15,23,40,.42); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 620px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 940px; }
.modal-h { padding: 18px 20px 6px; display: flex; justify-content: space-between; align-items: center; }
.modal-b { padding: 12px 20px; overflow-y: auto; }
.modal-f { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line-2); }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; font-size: 14px; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #a8322e; }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-art { background: var(--navy); color: #e6ecf4; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art h1 { color: #fff; font-size: 36px; max-width: 420px; }
.auth-art ul { padding-left: 18px; color: #c9d4e3; line-height: 1.9; }
.auth-art .roofs { position: absolute; right: -30px; bottom: -40px; width: 380px; opacity: .13; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-box { width: 100%; max-width: 380px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* bars */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bars .b i { display: block; width: 100%; max-width: 34px; background: var(--navy-2); border-radius: 5px 5px 0 0; min-height: 2px; }
.bars .b i.alt { background: var(--brass); }
.bars .b span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.hbar { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.hbar i { display: block; height: 100%; background: var(--navy-2); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

@media (max-width: 1000px) {
  .g4 { grid-template-columns: 1fr 1fr; } .g-main, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 16px 96px; }
  .g2, .form.cols { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40; }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 0; }
  .bottomnav a.on { color: var(--navy); font-weight: 600; }
  .bottomnav svg { width: 22px; height: 22px; }
  .auth { grid-template-columns: 1fr; } .auth-art { display: none; }
  .hide-m { display: none !important; }
  .kv { grid-template-columns: 100px 1fr; }
  .step { grid-template-columns: 70px 1fr 36px; }
  .step .stepkind { grid-column: 2; } .step .steptarget { grid-column: 1 / -1; }
  .modal { max-height: calc(100vh - 16px); } .overlay { padding: 8px; align-items: end; }
  .tablewrap { max-height: none; }
}
@media print { .side, .bottomnav, .btn { display: none !important; } .shell { display: block; } }
.btn svg { width: 16px; height: 16px; flex: none; }
.pill svg { width: 12px; height: 12px; }
.ti svg { width: 15px; height: 15px; }
/* rich editor */
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.toolbar .btn svg { width: 14px; height: 14px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.imggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.imggrid.big { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.imgtile { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; padding: 0; cursor: pointer; aspect-ratio: 3 / 2; display: block; text-align: left; }
.imgtile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.imgtile:hover { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass-soft); }
.imgtile .cap { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.92); font-size: 12px; padding: 4px 7px; color: var(--ink); }
.imgtile .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: none; place-items: center; }
.imgtile .x svg { width: 14px; height: 14px; }
.imgtile:hover .x { display: grid; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-weight: 400; }
.seg button { border: 0; background: #fff; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; }
.pv-stage { background: #eceae4; display: flex; justify-content: center; overflow: auto; }
.pv-stage iframe { height: 560px; border: 0; background: #fff; max-width: 100%; transition: width .2s; }
.tplcard { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; cursor: pointer; text-align: left; padding: 0; }
.tplcard:hover { border-color: var(--brass); }
.tplcard .th { aspect-ratio: 16 / 9; background: #efece5 center / cover no-repeat; display: grid; place-items: center; color: var(--muted); }
.tplcard .th svg { width: 30px; height: 30px; opacity: .5; }
.tplcard .bd { padding: 10px 12px; }
.chipsel { display: flex; flex-wrap: wrap; gap: 6px; }
.chipsel label { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 99px; padding: 4px 11px; font-size: 13px; cursor: pointer; background: #fff; user-select: none; }
.chipsel input { display: none; }
.chipsel label:has(input:checked) { background: var(--navy); color: #fff; border-color: var(--navy); }
.chipsel .n { font-size: 11px; opacity: .7; }
.steps { display: flex; gap: 6px; margin-bottom: 14px; }
.steps span { flex: 1; text-align: center; font-size: 13px; padding: 7px; border-radius: 8px; background: var(--line-2); color: var(--muted); font-weight: 600; }
.steps span.on { background: var(--navy); color: #fff; }
.steps span.done { background: var(--ok-soft); color: var(--ok); }
.aud { position: sticky; top: 0; background: var(--brass-soft); border: 1px solid #ecdcbc; border-radius: 10px; padding: 10px 14px; }
.aud .n { font: 600 26px var(--serif); }
.progress { height: 6px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ok); }
@media (max-width: 760px) { .pv-stage iframe { height: 480px; } }
@media (max-width: 1000px) { .audwrap { order: -1; } .aud { z-index: 2; } }
