/* Emailing Portal - design system */
:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --subtle: #f8fafc;
  --border: #e6e9f0;
  --border-strong: #d7dde7;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-soft: #eef3ff;
  --primary-border: #c7d7fe;
  --success: #16a34a;
  --success-text: #15803d;
  --success-soft: #ecfdf3;
  --success-border: #bbf7d0;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --violet-soft: #f3f0ff;
  --orange-soft: #fff7ed;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .03);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
  --sidebar-w: 280px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.55 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.25; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 14px; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }
code { font-family: var(--mono); font-size: .88em; background: #f1f5f9; padding: 1px 6px; border-radius: 6px; }
.icon { flex-shrink: 0; display: inline-block; vertical-align: middle; }

/* ------------------------------------------------------------ layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--panel); border-right: 1px solid var(--border); flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 60;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 26px 26px 22px; }
.logo-tile {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8); box-shadow: 0 6px 16px rgba(37, 99, 235, .25); flex-shrink: 0;
}
.logo-tile.sm { width: 34px; height: 34px; border-radius: 9px; }
.brand-name { font-weight: 700; font-size: 18px; line-height: 1.2; }
.brand-sub { font-size: 11px; letter-spacing: .16em; color: var(--muted); font-weight: 500; }
.nav { padding: 6px 16px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 14px; color: var(--text-2); padding: 11px 14px; border-radius: 11px; font-weight: 500; font-size: 15.5px; }
.nav a .icon { color: var(--muted); }
.nav a:hover { background: #f4f6fa; text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav a.active .icon { color: var(--primary); }
.nav-section { font-size: 11px; letter-spacing: .12em; color: var(--muted-2); padding: 14px 14px 4px; font-weight: 600; }
.userbox { border-top: 1px solid var(--border); padding: 18px 16px 16px; }
.user-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #f1f5f9; border: 1px solid var(--border); display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--text-2); flex-shrink: 0; }
.avatar.dark { background: #0f172a; color: #fff; border: 0; border-radius: 10px; }
.user-email { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-status { font-size: 12.5px; color: var(--success-text); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); display: inline-block; flex-shrink: 0; }
.dot.blue { background: var(--primary); }
.dot.gray { background: var(--muted-2); }
.dot.red { background: var(--danger); }
.dot.yellow { background: var(--warning); }

.main { flex: 1; min-width: 0; padding: 0 0 60px; }
.content { padding: 0 40px; max-width: 1400px; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 26px 40px 22px; margin: 0 -40px 32px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.page-head .title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .subtitle { color: var(--muted); margin-top: 4px; font-size: 15px; }
.page-head .back { font-size: 14px; display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; color: var(--muted); }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.save-state { color: var(--muted); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.save-state .icon { color: var(--success); }

/* mobile top bar + bottom tabs (hidden on desktop) */
.topbar, .tabbar, .scrim { display: none; }

/* ------------------------------------------------------------ cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 30px; margin-bottom: 24px; }
.card-head { display: flex; align-items: flex-start; gap: 14px; padding-bottom: 22px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.card-head .ttl { flex: 1; min-width: 0; }
.card-head h2 { margin: 0; font-size: 19px; }
.card-head .sub { color: var(--muted); font-size: 14.5px; margin-top: 2px; }
.icon-tile { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--primary-soft); color: var(--primary); }
.icon-tile.green { background: var(--success-soft); color: var(--success); }
.icon-tile.violet { background: var(--violet-soft); color: #4f46e5; }
.icon-tile.orange { background: var(--orange-soft); color: #ea580c; }
.icon-tile.gray { background: #f1f5f9; color: var(--text-2); }
.icon-tile.wa { background: #e8faf0; color: #16a34a; }
.icon-tile.sm { width: 32px; height: 32px; border-radius: 8px; }
.grid { display: grid; gap: 24px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.stack > .card { margin-bottom: 0; }
.stat { padding: 20px 22px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.stat .sub { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border-strong); background: #fff;
  color: var(--text); padding: 9px 16px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 500; font-size: 14.5px;
  white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; text-decoration: none !important; line-height: 1.3;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, .3); }
.btn.primary:hover { background: var(--primary-600); }
.btn.lg { padding: 12px 22px; font-size: 15.5px; font-weight: 600; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #f1f5f9; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; font-size: 13.5px; display: inline-flex; align-items: center; gap: 5px; padding: 0; }

/* ------------------------------------------------------------ forms */
label, .label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 8px; color: var(--text-2); }
.field { margin-bottom: 22px; }
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.field-label label { margin: 0; text-transform: uppercase; letter-spacing: .09em; font-size: 12.5px; }
.field-label .aside { font-size: 12.5px; color: var(--muted); }
.field-label .aside.chip-hint { background: #f1f5f9; border-radius: 6px; padding: 2px 8px; color: var(--text-2); }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 8px; }
.hint-inline { color: var(--muted-2); font-weight: 400; text-transform: none; letter-spacing: 0; }
input[type=text], input[type=email], input[type=url], input[type=number], input[type=password], input[type=datetime-local], input[type=search], input[type=tel], select, textarea {
  width: 100%; height: 46px; padding: 0 16px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font: inherit; font-size: 15px;
  background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
select[multiple] { height: auto; background-image: none; padding: 8px; }
textarea { height: auto; min-height: 92px; padding: 12px 16px; resize: vertical; line-height: 1.5; }
textarea.code, input.mono { font-family: var(--mono); font-size: 13.5px; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
input:disabled, input[readonly], select:disabled { background: var(--subtle); color: var(--text-2); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--primary); }
.affix { position: relative; }
.affix input { padding-right: 130px; }
.affix .suffix { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--muted-2); font-size: 14px; pointer-events: none; white-space: nowrap; }
.affix .suffix.pill { pointer-events: auto; }
.affix .end-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: grid; place-items: center; }
.affix .end-btn:hover { background: #f1f5f9; color: var(--text); }
.affix.has-btn input { padding-right: 48px; }
.row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 170px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 400; margin: 0 16px 8px 0; cursor: pointer; text-transform: none; letter-spacing: 0; font-size: 14.5px; color: var(--text); }
.inforow { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 13px 16px; background: var(--subtle); font-size: 14.5px; flex-wrap: wrap; }
.inforow .icon { color: var(--primary); }
.inforow .end { margin-left: auto; color: var(--muted); font-size: 13.5px; }
.status-lines { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--muted); margin: 6px 0 18px; padding: 12px 14px; background: var(--subtle); border-radius: 10px; }
.status-lines strong { color: var(--text-2); font-weight: 600; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }

/* ------------------------------------------------------------ tables */
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--subtle); font-weight: 600; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fafbff; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: #f1f5f9; color: var(--text-2); border: 1px solid transparent; white-space: nowrap; }
.badge.green { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.badge.blue { background: var(--primary-soft); color: #1e40af; border-color: var(--primary-border); }
.badge.yellow { background: var(--warning-soft); color: #92400e; border-color: var(--warning-border); }
.badge.red { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.badge.outline { background: #fff; border-color: var(--border-strong); }
.badge.lg { padding: 5px 13px; font-size: 13.5px; }
.badge.mono { font-family: var(--mono); font-weight: 500; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #eef2ff; color: #3730a3; font-size: 12px; margin: 1px 3px 1px 0; font-weight: 500; }

.banner { padding: 13px 16px; border-radius: 12px; margin-bottom: 20px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.banner.warn { background: var(--warning-soft); border: 1px solid var(--warning-border); color: #92400e; }
.banner.info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.banner.ok { background: var(--success-soft); border: 1px solid var(--success-border); color: var(--success-text); }
.empty { text-align: center; color: var(--muted); padding: 44px 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ toasts & modals */
#toasts { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); max-width: 400px; font-size: 14px; }
.toast.error { background: var(--danger); }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 900; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 580px; padding: 26px; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 920px; }
.modal h2 { font-size: 19px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* ------------------------------------------------------------ templates */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.tpl-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.tpl-thumb { height: 220px; overflow: hidden; background: #f4f5f7; position: relative; border-bottom: 1px solid var(--border); cursor: pointer; }
.tpl-thumb iframe { width: 640px; height: 900px; border: 0; transform: scale(.38); transform-origin: 0 0; pointer-events: none; }
.tpl-card .meta { padding: 14px 16px 10px; flex: 1; }
.tpl-card .meta .name { font-weight: 600; }
.tpl-card .acts { display: flex; gap: 6px; padding: 0 16px 16px; flex-wrap: wrap; }

/* ------------------------------------------------------------ builder */
.builder-top { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.builder-top .field { margin: 0; }
.builder { display: grid; grid-template-columns: 210px minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.palette, .props { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px; }
.palette .pal-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: 10px; margin-bottom: 8px; cursor: grab; background: #fff; user-select: none; font-size: 14px; }
.palette .pal-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.palette .pal-item .ico { width: 20px; text-align: center; font-weight: 700; color: var(--primary); }
.canvas-wrap { background: #e9ecf2; border-radius: var(--radius); padding: 22px; min-height: 500px; }
.canvas { margin: 0 auto; background: #fff; min-height: 300px; transition: width .2s; }
.canvas.mobile { width: 375px !important; }
.canvas .blk { position: relative; outline: 1px dashed transparent; cursor: pointer; }
.canvas .blk:hover { outline-color: #93c5fd; }
.canvas .blk.selected { outline: 2px solid var(--primary); z-index: 1; }
.canvas .blk .blk-tools { display: none; position: absolute; top: -14px; right: 6px; gap: 2px; z-index: 5; }
.canvas .blk:hover .blk-tools, .canvas .blk.selected .blk-tools { display: flex; }
.canvas .blk-tools button { border: 0; background: var(--primary); color: #fff; width: 26px; height: 24px; border-radius: 5px; cursor: pointer; font-size: 12px; }
.canvas .blk-tools button.del { background: var(--danger); }
.canvas .blk-label { display: none; position: absolute; top: -14px; left: 6px; background: var(--primary); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 5px; z-index: 5; }
.canvas .blk.selected .blk-label, .canvas .blk:hover .blk-label { display: block; }
.canvas .drop-line { height: 4px; background: var(--primary); border-radius: 2px; margin: -2px 0; position: relative; z-index: 6; }
.canvas .empty-drop { border: 2px dashed #cbd5e1; margin: 20px; padding: 60px 20px; text-align: center; color: var(--muted); border-radius: 10px; }
.canvas .blk p { margin: 0 0 12px; }
.canvas [contenteditable="true"] { outline: 2px dashed var(--warning); cursor: text; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: #fff; padding: 8px 12px; cursor: pointer; font: inherit; font-size: 13.5px; white-space: nowrap; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--primary); color: #fff; }
.props .seg { display: flex; }
.props .seg button { flex: 1; }
.color-row { display: flex; gap: 6px; align-items: center; }
.color-row input[type=color] { width: 46px; height: 46px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 10px; background: #fff; flex-shrink: 0; }
.mini-toolbar { display: flex; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.mini-toolbar button, .mini-toolbar select { font-size: 12px; padding: 4px 8px; height: auto; border: 1px solid var(--border-strong); background: #fff; border-radius: 6px; cursor: pointer; width: auto; background-image: none; }
.html-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.html-editor textarea { height: calc(100vh - 260px); min-height: 400px; }
.preview-frame { width: 100%; height: calc(100vh - 260px); min-height: 400px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.preview-frame.mobile { width: 375px; display: block; margin: 0 auto; }

/* ------------------------------------------------------------ chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; max-height: 190px; overflow-y: auto; padding: 10px; border: 1px solid var(--border-strong); border-radius: 12px; background: #fff; }
.chip { padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 999px; cursor: pointer; user-select: none; font-size: 13.5px; background: #fff; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* lead finder industry groups */
.ind-group { margin-bottom: 12px; }
.ind-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
details.ind-group summary { cursor: pointer; margin-bottom: 8px; font-size: 14px; }

/* ------------------------------------------------------------ automations */
.recipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.recipe { border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: #fff; cursor: pointer; text-align: left; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, box-shadow .15s; box-shadow: var(--shadow); }
.recipe:hover { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .08); }
.recipe .r-head { display: flex; gap: 12px; align-items: center; }
.recipe .r-title { font-weight: 600; }
.recipe .r-desc { color: var(--muted); font-size: 13.5px; }
.recipe .r-flow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; color: var(--muted-2); }
.recipe .r-flow .icon-tile { width: 28px; height: 28px; border-radius: 7px; }
.sentence { font-size: 15px; color: var(--text-2); line-height: 1.7; }
.sentence b { color: var(--text); }
.flow { display: flex; flex-direction: column; align-items: stretch; max-width: 760px; }
.flow .node { background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.flow .node.trigger { border-color: #fcd9a8; }
.flow .node.open { border-color: var(--primary-border); box-shadow: 0 0 0 4px rgba(37, 99, 235, .06); }
.flow .node-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.flow .node-head .t { flex: 1; min-width: 0; }
.flow .node-head .t .k { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.flow .node-head .t .s { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.flow .node-body { padding: 4px 18px 18px; border-top: 1px solid var(--border); padding-top: 18px; }
.flow .node-tools { display: flex; gap: 2px; }
.flow .connector { display: flex; flex-direction: column; align-items: center; padding: 2px 0; }
.flow .connector .line { width: 2px; height: 14px; background: var(--border-strong); }
.flow .connector .add { width: 30px; height: 30px; border-radius: 50%; border: 1px dashed var(--border-strong); background: #fff; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.flow .connector .add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.flow .end { text-align: center; color: var(--muted); font-size: 13px; padding: 4px; }
.picker-group { margin-bottom: 18px; }
.picker-group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.picker-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pick { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: #fff; display: flex; gap: 12px; align-items: flex-start; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.pick:hover { border-color: var(--primary); background: #fafcff; }
.pick.on { border-color: var(--primary); background: var(--primary-soft); }
.pick .p-t { font-weight: 600; font-size: 14px; }
.pick .p-d { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.run-log { font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------ misc */
.bars { display: flex; gap: 5px; align-items: flex-end; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column-reverse; min-width: 6px; max-width: 32px; }
.bars .bar span { display: block; }
.bars .bar span:last-child { border-radius: 4px 4px 0 0; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.progress { height: 8px; background: #eef0f4; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); }
.reply-body { white-space: pre-wrap; background: var(--subtle); border-radius: 10px; padding: 12px; margin-top: 8px; font-size: 14px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }

/* Sign-in */
.signin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.signin-card { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 36px 32px; max-width: 430px; width: 100%; text-align: center; box-shadow: 0 10px 30px rgba(16, 24, 40, .08); }
.signin-card .logo-tile { margin: 0 auto 14px; }
.brand-lg { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted-2); font-size: 13px; margin: 20px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1200px) {
  .builder { grid-template-columns: 1fr; }
  .palette { position: static; display: flex; flex-wrap: wrap; gap: 6px; max-height: none; }
  .palette h3, .palette .hint { width: 100%; }
  .palette .pal-item { margin: 0; }
  .props { position: static; max-height: none; }
  .html-editor { grid-template-columns: 1fr; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  body { font-size: 15px; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100%; width: min(86vw, 300px);
    transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-lg); z-index: 200;
  }
  body.drawer-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 150; opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  body.drawer-open { overflow: hidden; }
  .topbar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 100; height: 62px; padding: 0 12px;
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  }
  .topbar .hamburger { border: 0; background: transparent; padding: 8px; border-radius: 10px; cursor: pointer; color: var(--text); display: grid; place-items: center; }
  .topbar .hamburger:hover { background: #f1f5f9; }
  .topbar .tb-title { font-weight: 700; font-size: 17px; line-height: 1.15; }
  .topbar .tb-sub { font-size: 12px; color: var(--muted); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    background: #fff; border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11.5px; color: var(--muted); padding: 4px 0; text-decoration: none; }
  .tabbar a.active { color: var(--primary); font-weight: 600; }
  .main { padding-bottom: 96px; }
  .content { padding: 0 16px; }
  .page-head { padding: 18px 16px; margin: 0 -16px 20px; }
  .page-head h1 { font-size: 22px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn.primary { flex: 1; }
  .card { padding: 20px 18px; border-radius: 14px; margin-bottom: 16px; }
  .card-head { padding-bottom: 16px; margin-bottom: 18px; }
  .card-head h2 { font-size: 17px; }
  .grid, .stack { gap: 16px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .affix input { padding-right: 110px; }
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92vh; overflow-y: auto; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
  .modal .foot .btn { flex: 1; }
  .picker-grid { grid-template-columns: 1fr; }
  #toasts { left: 16px; right: 16px; bottom: 90px; }
  .toast { max-width: none; }
  .tpl-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .tpl-thumb { height: 170px; }
  .tpl-thumb iframe { transform: scale(.3); }
  .canvas-wrap { padding: 10px; }
  table.data th, table.data td { padding: 10px 8px; font-size: 14px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 520px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 22px; }
  .row > .field { min-width: 100%; }
}

/* ---------- GrandPine branding, as the Helpdesk and the other staff portals ---------- */
.brand-logo { height: 28px; width: auto; display: block; }
.brand .brand-name { border-left: 1px solid var(--border); padding-left: 12px; line-height: 26px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; color: #004b93; }
.tb-logo { height: 22px; width: auto; display: block; }

/* Staff sign-in: the CRM's sign-in page (Helpdesk styles.css .sso-*) */
.sso-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f4f6f9; color: #191c1e; font-size: 14px; line-height: 20px; }
.sso-inner { width: 100%; max-width: 440px; padding: 16px; }
.sso-brand { text-align: center; margin-bottom: 24px; }
.sso-brand h1 { margin: 0; font-family: 'Hanken Grotesk', system-ui, sans-serif; font-weight: 700; font-size: calc(1.375rem + 1.5vw); line-height: 1.2; letter-spacing: -0.02em; }
@media (min-width: 1200px) { .sso-brand h1 { font-size: 2.5rem; } }
.sso-brand img { height: 72px; width: auto; max-width: 100%; vertical-align: middle; }
.sso-app { margin: 8px 0 0; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em; color: #43474e; }
.sso-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 32px; margin-bottom: 16px; word-wrap: break-word; }
.sso-alert { padding: 12px 14px; margin-bottom: 16px; border-radius: 6px; font-size: 13.5px; background: #fef2f2; color: #b91c1c; }
.sso-status { font-size: 0.875em; text-align: center; margin: 0 0 16px; color: #1a3a5c; }
.sso-btn { width: 100%; height: 48px; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 6px 12px; font-family: inherit; font-size: 16px; font-weight: 400; line-height: 1.5;
  color: #6c757d; background: transparent; border: 1px solid #6c757d; border-radius: 8px; cursor: pointer; text-decoration: none; user-select: none;
  transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out; }
.sso-btn:hover { color: #ffffff; background: #6c757d; border-color: #6c757d; text-decoration: none; }
.sso-btn:focus-visible { outline: 0; box-shadow: 0 0 0 0.25rem rgba(108, 117, 125, 0.5); }
.sso-btn:disabled { color: #6c757d; background: transparent; opacity: 0.65; pointer-events: none; }
.sso-spinner { display: inline-block; width: 1rem; height: 1rem; margin-right: 8px; vertical-align: -0.125em; border: 0.2em solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sso-spin 0.75s linear infinite; }
@keyframes sso-spin { to { transform: rotate(360deg); } }
.sso-error { color: #dc3545; font-size: 0.875em; margin-top: 8px; }
.sso-note { margin-top: 24px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.sso-note > div { display: flex; gap: 8px; padding: 16px; border-radius: 8px; background: #e0f2fe; }
.sso-note .icon { color: #1a3a5c; margin-top: 2px; flex-shrink: 0; }
.sso-note span:last-child { font-size: 0.875em; color: #1a3a5c; line-height: 1.5; }
