:root {
  --brand: #4f7ab5;
  --brand-600: #3d6399;
  --brand-700: #2f4e7a;
  --brand-100: #d9e5f5;
  --brand-50: #eef3fa;
  --navy: #1c2b45;
  --ink: #111827;
  --muted: #6b7280;
  --soft: #9ca3af;
  --line: #e8ecf2;
  --line-2: #f1f4f8;
  --bg: #f8fafc;
  --card: #ffffff;
  --green: #16a34a; --green-bg: #ecfdf3;
  --amber: #d97706; --amber-bg: #fffbeb;
  --red: #dc2626;   --red-bg: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--brand-100); border-top-color: var(--brand); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { height: 58px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 20px; gap: 16px; }
.brandbox { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brandbox img { height: 26px; width: auto; }
.brandbox .sep { width: 1px; height: 22px; background: var(--line); }
.funnel-pick { position: relative; min-width: 0; max-width: 100%; }
.funnel-pick select { appearance: none; border: 0; background: transparent; font-weight: 600; padding: 6px 26px 6px 8px; border-radius: 8px; cursor: pointer; max-width: 100%; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.funnel-pick select:hover { background: var(--line-2); }
.funnel-pick::after { content: ''; position: absolute; right: 9px; top: 50%; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.tabs { display: flex; gap: 4px; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-weight: 500; cursor: pointer; }
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--ink); background: var(--line-2); }
.tab.on { color: var(--ink); background: #eef1f5; font-weight: 600; }
.top-right { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #d5dbe4; background: #fbfcfd; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-50); color: var(--brand-700); font-weight: 600; display: grid; place-items: center; border: 0; cursor: pointer; font-size: 13px; }

/* ---------- page ---------- */
.page { max-width: 1040px; margin: 0 auto; padding: 30px 20px 80px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; font-weight: 700; color: var(--navy); }
.head .sub { color: var(--muted); margin-top: 4px; font-size: 13px; }
.head .sub a { color: var(--brand-600); text-decoration: none; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.live { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; margin-right: 4px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(22,163,74,.5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.45); } 70% { box-shadow: 0 0 0 7px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }
.select { position: relative; }
.select select { appearance: none; height: 34px; padding: 0 30px 0 12px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-weight: 500; cursor: pointer; }
.select::after { content: ''; position: absolute; right: 12px; top: 50%; width: 5px; height: 5px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }

.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; min-width: 0; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.grid > .card { margin-top: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-t { display: flex; align-items: center; gap: 7px; font-weight: 500; font-size: 14.5px; color: var(--ink); }
.card-s { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.info { width: 15px; height: 15px; color: var(--soft); flex: none; cursor: help; }
.corner { width: 16px; height: 16px; color: var(--muted); }

/* metric cards */
.metric .num { font-size: 32px; font-weight: 600; letter-spacing: -.02em; margin: 14px 0 12px; color: var(--ink); line-height: 1; }
.metric .num small { font-size: 16px; font-weight: 600; margin-left: 1px; }
.cmp { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12px; padding: 2px 7px; border-radius: 999px; }
.chip.up { color: var(--green); background: var(--green-bg); }
.chip.down { color: var(--red); background: var(--red-bg); }
.chip.flat { color: var(--muted); background: var(--line-2); }

/* status */
.status-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.st { border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px; background: #fcfdfe; min-width: 0; }
.st-h { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--soft); }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.dot.warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.st-d { color: var(--muted); font-size: 12px; margin-top: 7px; line-height: 1.45; overflow-wrap: anywhere; }
.st-d a { color: var(--brand-600); text-decoration: none; font-weight: 500; }
.st.bad { border-color: #fbd5d5; background: #fffafa; }
.st.warn { border-color: #fde9c3; background: #fffdf7; }

/* charts */
.chart { margin-top: 18px; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: Inter, system-ui, sans-serif; }
.legend { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.legend label { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none; }
.legend input { display: none; }
.legend .box { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--c); display: grid; place-items: center; }
.legend input:checked + .box { background: var(--c); }
.legend input:checked + .box::after { content: ''; width: 7px; height: 4px; border-left: 1.8px solid #fff; border-bottom: 1.8px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.empty { display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 13px; padding: 34px 10px; }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--navy); color: #fff; padding: 9px 11px; border-radius: 9px; font-size: 12px; line-height: 1.55; box-shadow: 0 8px 24px rgba(16,24,40,.18); }
.tip b { font-weight: 600; }
.callout { margin-top: 14px; display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--brand-700); background: var(--brand-50); border-radius: 10px; padding: 10px 12px; }
.callout svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* question cards */
.q-rows { margin-top: 16px; display: grid; gap: 10px; }
.q-row { display: grid; grid-template-columns: minmax(0, 1fr) 52px; gap: 12px; align-items: center; }
.q-bar { position: relative; height: 34px; border-radius: 8px; background: #f6f8fb; overflow: hidden; }
.q-bar i { position: absolute; inset: 0 auto 0 0; background: var(--brand-100); border-radius: 8px; transition: width .5s ease; }
.q-bar span { position: relative; display: block; padding: 0 12px; line-height: 34px; font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--navy); }
.q-pct { text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.q-row.top .q-bar i { background: #c3d5ef; }

/* tables */
table.list { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
table.list th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.ok { color: #15803d; background: var(--green-bg); }
.pill.warn { color: #b45309; background: var(--amber-bg); }
.pill.bad { color: #b91c1c; background: var(--red-bg); }
.who b { display: block; font-weight: 600; }
.who span { color: var(--muted); font-size: 12px; }
.scroll-x { overflow-x: auto; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-50), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 40px rgba(16,24,40,.08); padding: 34px 30px; }
.auth-card img { height: 30px; }
.auth-card h1 { font-size: 21px; letter-spacing: -.01em; margin: 22px 0 6px; color: var(--navy); }
.auth-card p { color: var(--muted); margin: 0 0 20px; line-height: 1.55; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 6px; }
.field input { width: 100%; height: 42px; border-radius: 10px; border: 1px solid #d9dfe7; padding: 0 13px; outline: none; }
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.auth-card .btn { width: 100%; height: 42px; justify-content: center; border-radius: 10px; }
.msg { font-size: 12.5px; margin-top: 12px; min-height: 18px; }
.msg.err { color: var(--red); }
.msg.ok { color: var(--green); }
.linkbtn { background: none; border: 0; color: var(--brand-600); cursor: pointer; padding: 0; font-weight: 500; }

.fade-in { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (max-width: 1100px) {
  .topbar-in { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'brand right' 'tabs tabs'; height: auto; padding-top: 10px; row-gap: 6px; }
  .brandbox { grid-area: brand; } .top-right { grid-area: right; }
  .tabs { grid-area: tabs; justify-content: center; padding-bottom: 8px; }
}
@media (max-width: 900px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 20px 14px 60px; }
  .card { padding: 16px; }
  .metric .num { font-size: 26px; }
  .brandbox img { display: none; }
  .brandbox .sep { display: none; }
  .status-grid { grid-template-columns: minmax(0, 1fr); }
  .top-right .btn span { display: none; }
}

/* ===================== v2: workspace app ===================== */
a.tab { text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.pre { white-space: pre-wrap; margin: 0; line-height: 1.55; }
.nowrap { white-space: nowrap; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--line-2); padding: 1px 5px; border-radius: 5px; }
.btn.wide { width: 100%; justify-content: center; margin-top: 12px; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.linkbtn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-size: 13px; }
.linkbtn svg { width: 14px; height: 14px; }
.linkbtn.danger { color: var(--red); }
.iconbtn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; flex: none; text-decoration: none; }
.iconbtn:hover { background: var(--line-2); color: var(--ink); }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn.sm { width: 28px; height: 28px; }
.iconbtn.sm svg { width: 16px; height: 16px; }
.iconbtn.round { border: 1px solid var(--line); border-radius: 50%; width: 38px; height: 38px; color: var(--navy); }
.iconbtn.close { position: absolute; top: 14px; right: 14px; }
.chev { width: 15px; height: 15px; color: var(--muted); flex: none; }
.ws-btn { display: inline-flex; align-items: center; gap: 9px; border: 0; background: transparent; padding: 6px 8px; border-radius: 9px; cursor: pointer; font-weight: 600; min-width: 0; }
.ws-btn:hover { background: var(--line-2); }
.ws-logo { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; background: #fff; flex: none; }
.ws-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.ws-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.view-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0; cursor: pointer; }
.view-btn .chev { width: 20px; height: 20px; color: var(--navy); }
.head h1 .info, .head h1 span .info { width: 16px; height: 16px; margin-left: 8px; vertical-align: middle; }
.head h1 .count { font-size: 20px; color: var(--muted); font-weight: 600; margin-left: 6px; }
.searchbox { display: inline-flex; align-items: center; gap: 6px; height: 34px; border-radius: 9px; border: 1px solid transparent; padding: 0 8px; cursor: text; color: var(--muted); }
.searchbox svg { width: 18px; height: 18px; flex: none; }
.searchbox input { width: 0; border: 0; outline: none; background: transparent; padding: 0; transition: width .2s; }
.searchbox.open { border-color: var(--line); background: #fff; }
.searchbox.open input { width: 180px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 0 11px; height: 32px; cursor: pointer; color: var(--muted); font-weight: 500; display: inline-grid; place-items: center; }
.seg button svg { width: 16px; height: 16px; }
.seg button.on { background: var(--brand-50); color: var(--brand-700); }

/* status chips */
.chip-status { display: inline-flex; align-items: center; font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 7px; white-space: nowrap; }
.chip-status.live { color: #15803d; background: var(--green-bg); }
.chip-status.draft { color: #4b5563; background: #f1f3f6; }
.chip-status.offline { color: #b91c1c; background: var(--red-bg); }
.chip-status.archived { color: #6b7280; background: #f1f3f6; text-decoration: line-through; }

/* funnels table */
.card.flush { padding: 0; overflow-x: auto; }
table.ftable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.ftable th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 12px 16px; background: #fafbfc; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.ftable td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.ftable tr:last-child td { border-bottom: 0; }
table.ftable tbody tr { cursor: pointer; transition: background .12s; }
table.ftable tbody tr:hover { background: #fbfcfe; }
table.ftable td.num { font-variant-numeric: tabular-nums; }
.fname { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fname b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.fname span { color: var(--muted); font-size: 12px; }
.thumb { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; background: #fff; flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.thumb i { font-style: normal; font-weight: 600; color: var(--brand-700); background: var(--brand-50); width: 100%; height: 100%; display: grid; place-items: center; }
.star { border: 0; background: none; padding: 4px; cursor: pointer; color: #c0c7d2; }
.star svg { width: 19px; height: 19px; fill: none; }
.star.on { color: #f59e0b; }
.star.on svg { fill: #f59e0b; }
.cpill { display: inline-flex; align-items: center; gap: 5px; color: var(--brand-700); background: var(--brand-50); border-radius: 7px; padding: 4px 9px; font-size: 12.5px; font-weight: 500; text-decoration: none; }
.cpill svg { width: 13px; height: 13px; }
.sbar-cell { min-width: 180px; }
.stagebar { display: flex; gap: 3px; height: 6px; border-radius: 4px; overflow: hidden; min-width: 140px; }
.stagebar i { display: block; border-radius: 3px; }
.row-menu { width: 44px; text-align: right; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.fcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 6px; text-decoration: none; color: inherit; transition: transform .12s, box-shadow .12s; }
.fcard:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(16,24,40,.08); }
.fcard-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.fcard-top .thumb { width: 44px; height: 44px; }
.fcard-stats { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin: 6px 0; flex-wrap: wrap; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: #fbfcfe; }

/* menus, modals, toasts */
.menu { position: absolute; z-index: 80; min-width: 210px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(16,24,40,.14); padding: 6px; animation: fade .12s ease; }
.menu button { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; font-size: 13.5px; }
.menu button:hover { background: var(--line-2); }
.menu button.on { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.menu button.danger { color: var(--red); }
.menu button svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.menu .mdot { width: 9px; height: 9px; border-radius: 50%; margin-left: auto; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-head { font-size: 11.5px; color: var(--muted); padding: 6px 10px 4px; font-weight: 500; }
.modal-wrap { position: fixed; inset: 0; z-index: 70; background: rgba(15, 23, 42, .35); display: grid; place-items: center; padding: 20px; animation: fade .15s ease; }
.modal { background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(16,24,40,.25); width: 100%; max-width: 460px; padding: 22px 24px; max-height: calc(100vh - 40px); overflow: auto; position: relative; }
.modal.wide { max-width: 820px; padding: 0; overflow: hidden; }
.modal-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-h h2 { margin: 0; font-size: 18px; color: var(--navy); }
.modal p { line-height: 1.55; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.field select, .field textarea, .modal textarea, .note-new textarea { width: 100%; border-radius: 10px; border: 1px solid #d9dfe7; padding: 10px 12px; outline: none; font: inherit; }
.field select { height: 42px; padding: 0 10px; background: #fff; }
.field small { display: block; margin-top: 5px; }
.modal textarea:focus, .note-new textarea:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.toast { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(16,24,40,.2); animation: fade .2s ease; transition: opacity .3s; }
.toast.bad { background: var(--red); }
.toast.out { opacity: 0; }

/* settings modal */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 460px; }
.settings aside { background: #fafbfc; border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; }
.settings aside b { padding: 0 10px 12px; color: var(--navy); }
.settings aside button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.settings aside button:hover { background: var(--line-2); color: var(--ink); }
.settings aside button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.settings aside button.danger { color: var(--red); margin-top: auto; }
.settings section { padding: 22px 26px; overflow: auto; max-height: calc(100vh - 80px); }
.settings h3 { margin: 0 0 6px; font-size: 16px; color: var(--navy); }
.stages-edit { display: grid; gap: 8px; margin: 12px 0; }
.se-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto auto; gap: 6px; align-items: center; }
.se-row input[type=color] { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; }
.se-row input:not([type]) , .se-row input[type=text] { height: 36px; border-radius: 8px; border: 1px solid #d9dfe7; padding: 0 10px; }
.radio { display: grid; gap: 8px; margin-top: 12px; }
.radio label { display: flex; align-items: center; gap: 10px; cursor: pointer; }

/* pipeline + contacts */
.stage { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 7px; color: var(--s); background: color-mix(in srgb, var(--s) 12%, white); white-space: nowrap; }
.stage-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; cursor: pointer; }
.stage-btn .chev { width: 14px; height: 14px; }
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { flex: 0 0 250px; background: #f6f8fb; border-radius: 12px; padding: 10px; transition: background .12s, outline .12s; }
.col.over { background: var(--brand-50); outline: 2px dashed var(--brand); }
.col-h { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 10px; }
.col-b { display: grid; gap: 8px; min-height: 40px; }
.ccard { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: grab; box-shadow: 0 1px 2px rgba(16,24,40,.04); position: relative; }
.ccard:hover { border-color: #cfd7e3; }
.ccard.dragging { opacity: .5; }
.ccard b { display: block; font-size: 13px; }
.ccard span { color: var(--muted); font-size: 11.5px; }
.cflag { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.cav { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-50); color: var(--brand-700); display: grid; place-items: center; font-weight: 600; font-size: 12.5px; flex: none; }
.cav.lg { width: 56px; height: 56px; font-size: 22px; }
table.ctable { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ctable th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 12px; background: #fafbfc; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.ctable td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.ctable tbody tr { cursor: pointer; }
table.ctable tbody tr:hover { background: #fbfcfe; }
.pcell { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.tag { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 12px; background: #fff; }
.tag.wrap { white-space: normal; max-width: none; }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 65; width: min(420px, 100vw); background: #fff; box-shadow: -12px 0 40px rgba(16,24,40,.14); transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.dr-h { background: linear-gradient(180deg, var(--brand-50), #fff); padding: 12px 18px 0; border-bottom: 1px solid var(--line); }
.dr-top { display: flex; justify-content: space-between; }
.dr-id { display: grid; justify-items: center; gap: 8px; text-align: center; }
.dr-id h2 { margin: 4px 0 0; font-size: 19px; color: var(--navy); }
.dr-actions { display: flex; justify-content: center; gap: 10px; margin: 14px 0; }
.dr-tabs { display: flex; gap: 4px; justify-content: center; }
.dr-tabs button { border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; }
.dr-tabs button.on { color: var(--brand-700); border-bottom-color: var(--brand); }
.dr-b { padding: 16px 20px 30px; overflow: auto; flex: 1; }
.pf { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.pf-l { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.pf-l svg { width: 14px; height: 14px; }
.pf a { color: var(--brand-700); text-decoration: none; }
.dr-foot { margin-top: 20px; }
.note-new { display: grid; gap: 8px; margin-bottom: 16px; }
.note-new .btn { justify-self: end; }
.note { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fcfdfe; }
.note-f { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 12px; }
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { display: flex; gap: 12px; padding: 8px 0; position: relative; }
.timeline p { margin: 0; font-size: 13px; }
.timeline span { color: var(--muted); font-size: 12px; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); flex: none; margin-top: 3px; z-index: 1; }
.tl-dot.note { background: var(--amber); }
.tl-dot.created { background: var(--green); }

/* funnel overview */
.ov { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.ov-stage { background: #eef2f7; border-radius: var(--radius); padding: 24px; display: grid; justify-items: center; gap: 12px; }
.device { background: #0f172a; border-radius: 34px; padding: 12px; box-shadow: 0 20px 50px rgba(15,23,42,.25); }
.device iframe { display: block; border: 0; background: #fff; border-radius: 24px; }
.device.mobile iframe { width: 375px; height: 720px; max-width: calc(100vw - 120px); }
.device.desktop { border-radius: 14px; padding: 10px; width: 100%; }
.device.desktop iframe { width: 100%; height: 640px; border-radius: 8px; }
.ov-side .card { margin-top: 0; }
.ov-side .card + .card, .ov-side #ovStatus .card { margin-top: 16px; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; margin-top: 12px; font-size: 13px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 500; overflow-wrap: anywhere; }
.kv a { color: var(--brand-700); text-decoration: none; }
ol.pages { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
ol.pages li { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 8px 10px; border-radius: 9px; background: #fafbfc; }
ol.pages small { margin-left: auto; color: var(--muted); }
.pnum { width: 22px; height: 22px; border-radius: 6px; background: var(--brand-50); color: var(--brand-700); display: grid; place-items: center; font-size: 11.5px; font-weight: 600; flex: none; }
.status-grid.col { grid-template-columns: minmax(0, 1fr); }

/* apps */
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.apps .card { margin-top: 0 !important; display: flex; flex-direction: column; }
.app-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.app-ic { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; background: #fff; }
.app-ic svg { width: 22px; height: 22px; color: var(--brand); }
.logo-txt { font-size: 14px; font-weight: 800; }
.app p { margin: 6px 0 0; line-height: 1.5; font-size: 13px; }
.legend.static label { cursor: default; }
.legend .box.filled { background: var(--c); }

@media (max-width: 900px) {
  .ov { grid-template-columns: minmax(0, 1fr); }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings aside { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .settings aside b { width: 100%; }
  .settings aside button.danger { margin-top: 0; }
  table.ftable th:nth-child(2), table.ftable td:nth-child(2), table.ftable th:nth-child(7), table.ftable td:nth-child(7) { display: none; }
}
@media (max-width: 640px) {
  .searchbox.open input { width: 120px; }
  .head-actions { flex-wrap: wrap; }
  table.ftable th:nth-child(5), table.ftable td:nth-child(5), table.ftable th:nth-child(4), table.ftable td:nth-child(4) { display: none; }
  .fname b { max-width: 160px; }
  .device.mobile iframe { width: 300px; height: 600px; }
}
.demo-bar { background: #1c2b45; color: #fff; text-align: center; font: 500 12.5px Inter, sans-serif; padding: 7px; }
.demo-bar a { color: #d9e5f5; }
/* integration pills */
.ipills { display: flex; flex-wrap: wrap; gap: 4px; }
.ipill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; padding: 3px 8px 3px 7px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--muted); white-space: nowrap; }
.ipill i { width: 7px; height: 7px; border-radius: 50%; background: var(--soft); }
.ipill.ok i { background: var(--green); } .ipill.warn i { background: var(--amber); } .ipill.bad i { background: var(--red); }
.ipill.bad { color: #b91c1c; border-color: #fbd5d5; } .ipill.wait i { background: #cbd5e1; animation: pulse 1.6s infinite; }
.int-cell { min-width: 230px; }
.fcard .int-cell { min-width: 0; margin: 4px 0; }
