:root {
  --bg: #f4f6fb; --panel: #ffffff; --text: #111827; --muted: #6b7280; --border: #e5e8ef; --hover: #f6f8fc; --head: #f8fafc;
  --primary: #1d5bd8; --primary-2: #2563eb; --primary-ink: #ffffff; --primary-soft: #e8efff;
  --ok: #15803d; --ok-soft: #e3f6ea; --warn: #b45309; --warn-soft: #fff1dc; --bad: #c81e1e; --bad-soft: #fde8e8; --info-soft: #eef2f8;
  --purple: #7c3aed; --purple-soft: #f1eaff; --orange: #ea580c; --orange-soft: #ffedd5; --green: #16a34a; --green-soft: #dcfce7;
  --side: #0b1b3f; --side-2: #10234f; --side-text: #c3cde4; --side-active: #1d5bd8;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.07);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --panel: #161b24; --text: #e6e9ef; --muted: #9aa4b2; --border: #283041; --hover: #1c2330; --head: #1a202b;
    --primary-soft: #18284a; --ok-soft: #12301f; --warn-soft: #3a2a10; --bad-soft: #3b1515; --info-soft: #1d2430;
    --purple-soft: #2a1d48; --orange-soft: #3a2310; --green-soft: #12301f; --side: #070f22; --side-2: #0b1730; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --panel: #161b24; --text: #e6e9ef; --muted: #9aa4b2; --border: #283041; --hover: #1c2330; --head: #1a202b;
  --primary-soft: #18284a; --ok-soft: #12301f; --warn-soft: #3a2a10; --bad-soft: #3b1515; --info-soft: #1d2430;
  --purple-soft: #2a1d48; --orange-soft: #3a2310; --green-soft: #12301f; --side: #070f22; --side-2: #0b1730; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 .count { font-weight: 500; color: var(--muted); font-size: 18px; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 13.5px; margin: 0 0 8px; font-weight: 600; }
code, .mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
.ic { flex: none; vertical-align: middle; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 14px 12px 24px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { color: #fff; font-weight: 700; font-size: 18px; padding: 4px 8px 18px; display: flex; gap: 10px; align-items: center; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary-2); display: grid; place-items: center; color: #fff; }
.brand small { display: block; font-size: 11px; font-weight: 400; color: #8fa0c4; margin-top: -2px; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6f80a6; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 8px 10px; border-radius: 8px; font-size: 13.5px; margin-bottom: 2px; }
.nav a:hover { background: var(--side-2); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 24px; height: 58px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 10; }
.topbar .spacer { flex: 1; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; color: var(--text); font: inherit; padding: 4px 6px; border-radius: 8px; }
.user-btn:hover { background: var(--hover); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #1d5bd8, #7c3aed); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.dropdown { position: absolute; right: 0; top: 44px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); min-width: 210px; padding: 6px; display: none; z-index: 20; }
.dropdown.open { display: block; }
.dropdown a, .dropdown button { display: flex; gap: 8px; align-items: center; width: 100%; padding: 8px 10px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--hover); text-decoration: none; }
.dropdown .meta { padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.menu-btn { display: none; }
.content { padding: 24px 28px; width: 100%; max-width: 1440px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.sub { color: var(--muted); margin: 3px 0 0; font-size: 13px; }

/* ---------- cards & kpis ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.card.flush > .card-head { padding: 16px 18px 0; }
.card-head h2 { margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-7-5 { grid-template-columns: minmax(0,7fr) minmax(0,5fr); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-row.six { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
.stat-row.six .stat { padding: 14px; gap: 12px; }
.stat-row.six .tile { width: 40px; height: 40px; }
.stat-row.six .value { font-size: 21px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; }
.stat .tile { width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .hint { color: var(--muted); font-size: 11.5px; }
.tile.blue { background: var(--primary-2); color: #fff; } .tile.green { background: #16a34a; color: #fff; } .tile.orange { background: #f97316; color: #fff; }
.tile.purple { background: #7c3aed; color: #fff; } .tile.red { background: #dc2626; color: #fff; } .tile.teal { background: #0d9488; color: #fff; }
.tile.soft-blue { background: var(--primary-soft); color: var(--primary-2); } .tile.soft-green { background: var(--green-soft); color: var(--green); }
.tile.soft-orange { background: var(--orange-soft); color: var(--orange); } .tile.soft-purple { background: var(--purple-soft); color: var(--purple); } .tile.soft-red { background: var(--bad-soft); color: var(--bad); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .hint { font-size: 11.5px; color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--head); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pager .spacer { flex: 1; }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; margin: 0 0 5px; }
label .req { color: var(--bad); }
.field { margin-bottom: 14px; }
.field .help { color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; height: 38px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
textarea { height: auto; min-height: 90px; resize: vertical; }
select[multiple] { height: auto; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary-2); }
input:disabled, select:disabled, textarea:disabled { background: var(--hover); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 13.5px; }
.check input { width: auto; height: auto; accent-color: var(--primary-2); }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; cursor: pointer; font-weight: 400; }
.radio-card:has(input:checked) { border-color: var(--primary-2); background: var(--primary-soft); }
.radio-card input { width: auto; height: auto; margin-top: 3px; accent-color: var(--primary-2); }
.radio-card .rc-body { flex: 1; }
.radio-card .rc-title { font-weight: 600; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 170px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.searchbox { position: relative; flex: 1; max-width: 340px; min-width: 200px; }
.searchbox .ic { position: absolute; left: 10px; top: 10px; color: var(--muted); }
.searchbox input { padding-left: 34px; }
.toolbar select { width: auto; }
.section-title { font-size: 13px; font-weight: 700; margin: 4px 0 12px; color: var(--text); }
.form-page { max-width: 980px; }

/* colour picker (swatch + hex code) */
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 46px; height: 38px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); cursor: pointer; flex: none; }
.color-row input[type=text] { flex: 1; min-width: 0; font-family: Consolas, monospace; }
details.style-box { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
details.style-box > summary { cursor: pointer; font-weight: 600; font-size: 13px; margin-bottom: 12px; color: var(--primary-2); }

/* chip select */
.chipsel { border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; background: var(--panel); min-height: 38px; }
.chipsel select { border: 0; height: 28px; width: auto; flex: 1; min-width: 140px; padding: 0 6px; background: transparent; }
.chipsel select:focus { outline: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; background: var(--primary-soft); color: var(--primary-2); white-space: nowrap; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 2px; font-size: 13px; line-height: 1; }
.chip.red { background: var(--bad-soft); color: var(--bad); }
.chip.green { background: var(--green-soft); color: var(--green); } .chip.orange { background: var(--orange-soft); color: var(--orange); } .chip.purple { background: var(--purple-soft); color: var(--purple); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.btn.primary:hover { background: var(--primary); }
.btn.outline { border-color: var(--primary-2); color: var(--primary-2); }
.btn.danger { color: var(--bad); border-color: #f5c2c2; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 20px; font-size: 14.5px; }
.btn.block { width: 100%; justify-content: center; }
.btn.link { border: 0; background: none; color: var(--primary-2); padding: 0; height: auto; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--info-soft); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--primary-soft); color: var(--primary-2); }
.badge.plain::before { display: none; }
.notice { padding: 11px 14px; border-radius: 8px; background: var(--info-soft); color: var(--text); margin-bottom: 14px; font-size: 13px; border: 1px solid var(--border); }
.notice.warn { background: var(--warn-soft); border-color: transparent; } .notice.bad { background: var(--bad-soft); border-color: transparent; } .notice.ok { background: var(--ok-soft); border-color: transparent; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }

/* tabs (underline) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 0; flex-wrap: wrap; padding: 0 16px; }
.tabs.standalone { padding: 0; margin-bottom: 18px; }
.tabs a { padding: 12px 12px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; font-size: 13.5px; }
.tabs a .n { color: var(--muted); font-weight: 400; }
.tabs a.active { color: var(--primary-2); border-color: var(--primary-2); }
.tabs a.active .n { color: var(--primary-2); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.seg-tabs { display: inline-flex; background: var(--hover); border-radius: 8px; padding: 3px; gap: 2px; }
.seg-tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; font: inherit; color: var(--muted); font-weight: 500; }
.seg-tabs button.active { background: var(--panel); color: var(--primary-2); box-shadow: var(--shadow); }

/* ---------- stepper ---------- */
.stepper { display: flex; align-items: flex-start; margin: 6px 0 26px; }
.step { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; text-align: center; font-size: 12.5px; color: var(--muted); }
.step::after { content: ""; position: absolute; top: 15px; left: calc(50% + 20px); right: calc(-50% + 20px); height: 2px; background: var(--border); }
.step:last-child::after { display: none; }
.step .dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--hover); border: 2px solid var(--border); font-weight: 700; color: var(--muted); margin-bottom: 6px; z-index: 1; }
.step.active { color: var(--primary-2); font-weight: 600; }
.step.active .dot { background: var(--primary-2); border-color: var(--primary-2); color: #fff; box-shadow: 0 0 0 4px var(--primary-soft); }
.step.done .dot { background: var(--primary-soft); border-color: var(--primary-2); color: var(--primary-2); }
.step.done::after { background: var(--primary-2); }
.wizard-foot { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); padding-top: 16px; margin-top: 8px; }

/* dropzone */
.dropzone { border: 2px dashed #c9d3e6; border-radius: 12px; padding: 44px 20px; text-align: center; background: var(--hover); cursor: pointer; transition: .15s; }
.dropzone.over, .dropzone:hover { border-color: var(--primary-2); background: var(--primary-soft); }
.dropzone .big { width: 54px; height: 54px; border-radius: 12px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--panel); color: var(--primary-2); border: 1px solid var(--border); }

/* ---------- modal + toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10,15,30,.5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 920px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
/* Notifications sit over the bottom-right corner, where wizard "Next" buttons also are: let clicks pass through. */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: #111827; color: #fff; padding: 11px 16px; border-radius: 10px; max-width: 400px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 13.5px; }
.toast.bad { background: var(--bad); } .toast.ok { background: #15803d; } .toast.info { background: #1e3a8a; }

/* ---------- auth ---------- */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-hero { background: linear-gradient(150deg, #1d5bd8 0%, #1e40af 55%, #172554 100%); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px; text-align: center; position: relative; overflow: hidden; }
.auth-hero::before, .auth-hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.06); }
.auth-hero::before { width: 420px; height: 420px; top: -140px; right: -120px; }
.auth-hero::after { width: 300px; height: 300px; bottom: -110px; left: -90px; }
.auth-hero .logo { width: 84px; height: 84px; border-radius: 20px; background: rgba(255,255,255,.14); display: grid; place-items: center; margin-bottom: 18px; }
.auth-hero h1 { font-size: 34px; color: #fff; }
.auth-hero .tag { opacity: .85; margin-top: 4px; }
.auth-hero .slogan { margin-top: 40px; font-size: 17px; line-height: 1.7; opacity: .95; }
.auth-hero .points { margin-top: 26px; font-size: 13px; opacity: .8; display: grid; gap: 6px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--panel); }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { font-size: 26px; margin-bottom: 4px; }
.input-ic { position: relative; }
.input-ic > .ic { position: absolute; left: 11px; top: 10px; color: var(--muted); }
.input-ic input { padding-left: 36px; height: 42px; }
.auth-row { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 18px; font-size: 13px; }

/* ---------- charts ---------- */
.chart-box { position: relative; height: 270px; }
.bar { height: 8px; background: var(--hover); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary-2); }
.legend { display: grid; gap: 8px; font-size: 13px; }
.legend .li { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 10px; height: 10px; border-radius: 50%; }
.legend .v { margin-left: auto; font-weight: 600; }

/* ---------- template cards ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.tpl-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.tpl-thumb { height: 230px; overflow: hidden; background: #eef1f6; position: relative; border-bottom: 1px solid var(--border); }
.tpl-thumb iframe { width: 640px; height: 900px; border: 0; transform: scale(.36); transform-origin: 0 0; pointer-events: none; background: #fff; }
.tpl-thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.tpl-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tpl-body .name { font-weight: 600; }
.tpl-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }

/* ---------- email builder ---------- */
.builder { display: grid; grid-template-columns: 250px minmax(0,1fr) 300px; gap: 16px; min-height: 72vh; }
.blocks-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.block-type { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border: 1px solid var(--border); border-radius: 10px; cursor: grab; background: var(--panel); user-select: none; font-size: 12px; color: var(--text); }
.block-type .ic { color: var(--primary-2); }
.block-type:hover { border-color: var(--primary-2); background: var(--primary-soft); }
.canvas-wrap { background: #e9edf4; border-radius: 12px; padding: 22px; overflow: auto; border: 1px solid var(--border); }
.canvas { max-width: 640px; margin: 0 auto; background: #fff; color: #1f2933; min-height: 420px; border-radius: 6px; padding: 8px 0; box-shadow: 0 4px 18px rgba(15,23,42,.08); }
.blk { position: relative; border: 2px solid transparent; cursor: pointer; }
.blk:hover { border-color: #c7d6fb; }
.blk.selected { border-color: var(--primary-2); }
.blk .blk-tools { position: absolute; right: 2px; top: 2px; display: none; gap: 2px; z-index: 2; }
.blk.selected .blk-tools, .blk:hover .blk-tools { display: flex; }
.blk-tools button { font-size: 11px; padding: 2px 7px; border: 0; border-radius: 4px; background: var(--primary-2); color: #fff; cursor: pointer; }
.drop-hint { height: 6px; margin: 0 8px; border-radius: 3px; }
.drop-hint.over { background: var(--primary-2); }
.canvas-empty { padding: 60px 20px; text-align: center; color: #8a94a3; }
iframe.preview { width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #fff; min-height: 520px; }

/* ---------- automation builder ---------- */
.auto-layout { display: grid; grid-template-columns: 220px minmax(0,1fr) 220px; gap: 16px; align-items: start; }
.palette-list { display: grid; gap: 6px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--panel); font-size: 13px; text-align: left; font: inherit; color: var(--text); width: 100%; }
.palette-item:hover { border-color: var(--primary-2); background: var(--primary-soft); }
.palette-item.active { border-color: var(--primary-2); background: var(--primary-soft); font-weight: 600; }
.palette-item .ic { color: var(--primary-2); }
.flow-canvas { background-color: var(--panel); background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 18px 18px; border: 1px solid var(--border); border-radius: 12px; min-height: 560px; overflow: auto; }
.flow { display: flex; flex-direction: column; align-items: center; padding: 24px 12px; }
.flow-node { background: var(--panel); border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 14px; min-width: 210px; max-width: 280px; box-shadow: var(--shadow); text-align: center; position: relative; }
.flow-node .t { font-size: 13px; font-weight: 600; display: flex; gap: 6px; align-items: center; justify-content: center; }
.flow-node .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.flow-node.trigger { border-color: #16a34a; background: var(--green-soft); }
.flow-node.trigger .t { color: #15803d; }
.flow-node.email { border-color: var(--primary-2); background: var(--primary-soft); } .flow-node.email .t { color: var(--primary-2); }
.flow-node.wait { border-color: #f59e0b; background: var(--warn-soft); } .flow-node.wait .t { color: var(--warn); }
.flow-node.cond { border-color: #ec4899; background: #fdf2f8; } .flow-node.cond .t { color: #be185d; }
.flow-node.end { border-color: var(--muted); }
.flow-node.selected { box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow); }
.flow-node .node-actions { display: none; gap: 4px; justify-content: center; margin-top: 6px; }
.flow-node:hover .node-actions, .flow-node.selected .node-actions { display: flex; }
.flow-line { width: 2px; height: 22px; background: #b6c2d9; position: relative; }
.flow-line::after { content: ""; position: absolute; bottom: -1px; left: -4px; border: 5px solid transparent; border-top-color: #b6c2d9; border-bottom: 0; }
.flow-add { font-size: 12px; border: 1px dashed #b6c2d9; background: var(--panel); border-radius: 999px; padding: 3px 12px; cursor: pointer; color: var(--muted); font: inherit; }
.flow-add:hover, .flow-add.target { border-color: var(--primary-2); color: var(--primary-2); background: var(--primary-soft); }
.branches { display: flex; gap: 28px; align-items: flex-start; }
.branch { display: flex; flex-direction: column; align-items: center; border-top: 2px solid #b6c2d9; padding-top: 8px; min-width: 230px; }
.branch-label { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.branch-label.yes { color: #15803d; background: var(--green-soft); } .branch-label.no { color: var(--bad); background: var(--bad-soft); }

/* misc */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 10px 22px; border-left: 2px solid var(--border); position: relative; margin-left: 6px; }
.timeline li .ic { position: absolute; left: -12px; top: 8px; background: var(--panel); color: var(--primary-2); border-radius: 50%; padding: 3px; border: 1px solid var(--border); width: 22px; height: 22px; }
.rule-row { display: grid; grid-template-columns: 1.2fr 1fr 1.2fr auto; gap: 6px; margin-bottom: 6px; }
.seg-group { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--hover); }
pre.code { background: var(--hover); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 12px; white-space: pre-wrap; word-break: break-all; border: 1px solid var(--border); }
.summary dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; font-size: 13px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 500; }
.thumb-sm { width: 150px; height: 190px; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; flex: none; background: #fff; }
.thumb-sm iframe { width: 640px; height: 820px; border: 0; transform: scale(.234); transform-origin: 0 0; pointer-events: none; }
.kebab { position: relative; display: inline-block; }
.kebab .dropdown { top: 30px; min-width: 170px; }

@media (max-width: 1100px) { .builder, .auto-layout { grid-template-columns: 1fr; } .g-7-5 { grid-template-columns: 1fr; } }
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .rule-row { grid-template-columns: 1fr 1fr; }
  .auth-split { grid-template-columns: 1fr; }
  .auth-hero { padding: 32px 20px; }
  .auth-hero .slogan, .auth-hero .points { display: none; }
  .stepper .step span.lbl { display: none; }
}
