/* ==========================================================================
   MailPilot — classic, softly rounded, a little modern.
   ========================================================================== */
:root {
  --bg: #f6f3ec;
  --bg-2: #efeade;
  --surface: #ffffff;
  --ink: #1d2433;
  --ink-2: #3d465a;
  --muted: #7a8194;
  --line: #e8e2d4;
  --line-2: #f0ebdf;
  --primary: #2f3a8f;
  --primary-600: #252f78;
  --primary-50: #eceefb;
  --accent: #d9a441;
  --success: #1c9a68;
  --success-50: #e4f6ee;
  --danger: #d34a4a;
  --danger-50: #fcebea;
  --warn: #b97a0c;
  --warn-50: #fdf3dd;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(29, 36, 51, .05), 0 2px 8px rgba(29, 36, 51, .04);
  --shadow: 0 2px 4px rgba(29, 36, 51, .04), 0 12px 32px rgba(29, 36, 51, .07);
  --shadow-lg: 0 24px 70px rgba(20, 26, 50, .25);
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(47, 58, 143, .08), transparent 60%),
    radial-gradient(700px 380px at -5% 10%, rgba(217, 164, 65, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1, h2 { font-family: var(--serif); font-weight: 600; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0; }
code { font-family: var(--mono); font-size: .88em; background: var(--bg-2); padding: 1px 6px; border-radius: 6px; }
small { font-size: 12.5px; }
.muted { color: var(--muted); }
.ico { flex: none; vertical-align: middle; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- header ---------- */
.topbar { position: sticky; top: 0; z-index: 50; padding: 14px 24px 0; }
.topbar-inner {
  width: 100%; margin: 0 auto;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 12px 10px 16px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(232, 226, 212, .9);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--serif); font-size: 20px; font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #3d4bb5, #262f78); box-shadow: 0 4px 10px rgba(47, 58, 143, .35); }
.nav { display: flex; gap: 4px; }
.nav-link { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; color: var(--ink-2); font-weight: 500; }
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-link.active { background: var(--primary-50); color: var(--primary); }
.search { position: relative; flex: 1; min-width: 160px; max-width: 420px; margin-left: auto; color: var(--muted); }
.search > .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search input { width: 100%; height: 40px; border: 1px solid transparent; background: var(--bg); border-radius: 999px; padding: 0 16px 0 40px; font: inherit; color: var(--ink); transition: .15s; }
.search input:focus { outline: none; background: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.search-results { position: absolute; top: calc(100% + 10px); left: 0; right: 0; min-width: 320px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 8px; max-height: 420px; overflow: auto; color: var(--ink); }
.sr-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px 10px 4px; }
.sr-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; color: var(--ink); }
.sr-item:hover, .sr-item.active { background: var(--bg); text-decoration: none; }
.sr-item small { margin-left: auto; color: var(--muted); }
.sr-empty { padding: 14px; color: var(--muted); text-align: center; }
.top-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: none; margin: 0; padding: 28px 24px 70px; box-sizing: border-box; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 32px; }
.page-head-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); margin-bottom: 14px; font-weight: 500; }
.back-link:hover { color: var(--primary); text-decoration: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 20px; border-radius: 999px;
  border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .12s, box-shadow .15s, background .15s, border-color .15s, color .15s;
  white-space: nowrap; text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-sm { height: 36px; padding: 0 15px; font-size: 14px; }
.btn-xl { height: 64px; padding: 0 38px; font-size: 18px; gap: 12px; }
.btn-primary { background: linear-gradient(180deg, #3a47a8, var(--primary)); color: #fff; box-shadow: 0 6px 16px rgba(47, 58, 143, .30); }
.btn-primary:hover:not([disabled]) { background: linear-gradient(180deg, #3a47a8, var(--primary-600)); box-shadow: 0 8px 22px rgba(47, 58, 143, .38); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover:not([disabled]) { background: #fff; border-color: #d8d0bd; }
.btn-soft { background: var(--primary-50); color: var(--primary); }
.btn-soft:hover:not([disabled]) { background: #e0e4f8; }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 6px 16px rgba(211, 74, 74, .28); }
.btn-danger:hover:not([disabled]) { background: #bf3d3d; }
.btn-danger-soft { background: var(--danger-50); color: var(--danger); }
.btn-danger-soft:hover:not([disabled]) { background: #f9dcda; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 50%; cursor: pointer; transition: .15s; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn.danger:hover { background: var(--danger-50); color: var(--danger); }

/* ---------- hero ---------- */
.hero { text-align: center; max-width: 720px; margin: 0 auto; padding: 10vh 0 6vh; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.hero-compact { padding: 34px 0 26px; gap: 14px; }
.hero h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.08; }
.hero-compact h1 { font-size: clamp(26px, 3.4vw, 34px); }
.hero .lead { color: var(--ink-2); font-size: 17px; max-width: 560px; }
.hero-compact .lead { font-size: 15.5px; }
.eyebrow { display: inline-flex; align-items: center; gap: 7px; background: #fff; border: 1px solid var(--line); padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--primary); font-weight: 600; box-shadow: var(--shadow-sm); }
.hero-types { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.hero-types span { font-size: 12px; letter-spacing: .06em; color: var(--muted); background: rgba(255,255,255,.7); border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px; }
.hero .btn-xl { margin-top: 6px; }

/* ---------- cards & stats ---------- */
.card { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.card-title { flex: 1; min-width: 180px; }
.card-title h2 { font-size: 22px; }
.card-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; max-width: 760px; margin-inline: auto; }
.stat { background: rgba(255,255,255,.75); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 16px 20px; text-align: center; box-shadow: var(--shadow-sm); }
.stat b { display: block; font-family: var(--serif); font-size: 28px; color: var(--primary); }
.stat span { color: var(--muted); font-size: 13px; }
.avatar { --h: 230; width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; font-weight: 700; color: hsl(var(--h) 45% 28%); background: hsl(var(--h) 60% 91%); flex: none; font-family: var(--serif); }
.avatar-lg { width: 54px; height: 54px; font-size: 18px; border-radius: 18px; }
.avatar-xl { width: 76px; height: 76px; font-size: 26px; border-radius: 24px; }
.select-pill { height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 0 14px; font: inherit; color: var(--ink); max-width: 240px; }

/* ---------- toolbar / table ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter { position: relative; color: var(--muted); }
.filter .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); }
.filter input { height: 40px; width: 260px; max-width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 0 16px 0 38px; font: inherit; color: var(--ink); }
.filter input:focus { outline: none; background: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.table-wrap { overflow: auto; border-radius: 14px; border: 1px solid var(--line-2); max-height: 62vh; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { position: sticky; top: 0; background: #faf8f2; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line-2); z-index: 1; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fcfbf7; }
.table tbody tr.selected { background: var(--primary-50); }
.table tbody tr.row-hl { animation: flash 2.4s ease; }
.col-check { width: 44px; padding-right: 0 !important; }
.col-act { width: 54px; text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-email { font-weight: 500; word-break: break-all; }
.dot { --h: 230; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: hsl(var(--h) 55% 62%); margin-right: 10px; }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--success-50); color: var(--success); }
.badge-bad { background: var(--danger-50); color: var(--danger); }
.badge-muted { background: var(--bg-2); color: var(--muted); }
.empty-inline { padding: 26px; text-align: center; color: var(--muted); }
.empty { text-align: center; padding: 70px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-ico { width: 78px; height: 78px; border-radius: 26px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; }

/* ---------- customers ---------- */
.cust-list { display: flex; flex-direction: column; gap: 14px; }
.cust-card { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 16px; align-items: center; background: #fff; border: 1px solid var(--line-2); border-radius: 22px; padding: 20px; color: var(--ink); box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .2s, border-color .2s; }
.cust-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d9d3ff; text-decoration: none; }
.cust-body h3 { font-size: 20px; font-family: var(--serif); }
.cust-open { display: inline-flex; align-items: center; gap: 4px; color: var(--primary); font-weight: 700; font-size: 14px; }
.cust-none { grid-column: 1 / -1; margin: 8px 0 0; padding-top: 10px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 14px; }
.send-report { grid-column: 1 / -1; list-style: none; margin: 8px 0 0; padding: 0; }
.send-report li { display: grid; grid-template-columns: minmax(150px, 220px) minmax(110px, 170px) 1fr; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); font-size: 14px; }
.send-count { font-weight: 700; }
.send-report-full { margin: 0; }
.history-scroll { max-height: 520px; overflow: auto; }
#autoCard h2 { font-size: 22px; margin: 0 0 4px; }
#autoCard > .muted { margin: 0 0 14px; }
.when-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.when-row input { flex: 1; min-width: 0; }
.form-error { color: var(--danger); margin: 0 0 4px; font-size: 14px; }
.or-line { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 2px 0 14px; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.dropzone.compact { padding: 14px 16px; margin-bottom: 14px; }
.dropzone.compact .dz-ico { width: 40px; height: 40px; border-radius: 14px; margin-bottom: 2px; }

/* ---------- profile ---------- */
.profile-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.profile-info { flex: 1; min-width: 220px; }
.profile-name { display: flex; align-items: center; gap: 6px; }
.profile-name h1 { font-size: 30px; }
.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.field small { color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--ink);
}
.field input, .field select, .field textarea, .input-group input {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: var(--radius-sm); padding: 11px 14px; transition: .15s;
}
.field input, .field select, .input-group input { height: 44px; padding-block: 0; }
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .input-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.input-group { display: flex; gap: 10px; align-items: center; }
.check { display: flex; gap: 10px; align-items: center; color: var(--ink-2); margin: 14px 0 4px; font-size: 14px; cursor: pointer; }
.sub { color: var(--muted); margin: 6px 0 18px; }
.hint, .warn { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 13.5px; margin-bottom: 16px; }
.hint { background: var(--warn-50); color: #7a5208; }
.warn { background: var(--danger-50); color: #9c2f2f; }
.hint .ico, .warn .ico { margin-top: 2px; }
.form-card h2 { font-size: 24px; }
.form-sep { margin: 8px 0 14px; padding-top: 18px; border-top: 1px dashed var(--line); font-size: 15px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.narrow { width: 100%; margin: 0; }
.advanced { margin: 4px 0 18px; }
.advanced summary { cursor: pointer; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.status-pill { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 999px; font-weight: 600; margin-bottom: 18px; }
.status-pill.ok { background: var(--success-50); color: var(--success); }
.status-pill.off { background: var(--warn-50); color: var(--warn); }
.switch-field { justify-content: flex-start; }
.switch { position: relative; width: 52px; height: 30px; display: inline-block; margin-top: 4px; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch i { position: absolute; inset: 0; background: #d5d0c2; border-radius: 999px; transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(22px); }

/* ---------- settings hub ---------- */
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.set-card {
  display: flex; flex-direction: column; gap: 10px; min-height: 230px;
  background: #fff; border: 1px solid var(--line-2); border-radius: 24px;
  padding: 26px; color: var(--ink); box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .2s, border-color .2s;
}
.set-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #d9d3ff; text-decoration: none; }
.set-ico { width: 58px; height: 58px; border-radius: 20px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.set-card h2 { font-size: 24px; margin-top: 6px; }
.set-card p { color: var(--ink-2); flex: 1; }
.set-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 14px; border-top: 1px dashed var(--line); }
.set-meta { color: var(--muted); font-size: 13px; font-weight: 600; }
.set-go { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-weight: 700; }
.set-switch { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 20px; }
.set-switch-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); color: var(--ink-2);
  font-weight: 600; box-shadow: var(--shadow-sm);
}
.set-switch-btn:hover { text-decoration: none; border-color: #cfd5f3; color: var(--primary); }
.set-switch-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-head .status-pill { margin: 0; }

/* ---------- tabs / segmented ---------- */
.tabs { display: inline-flex; gap: 4px; padding: 5px; background: rgba(255,255,255,.8); border: 1px solid var(--line); border-radius: 999px; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 18px; border-radius: 999px; color: var(--ink-2); font-weight: 600; }
.tab:hover { text-decoration: none; background: var(--bg); }
.tab.active { background: var(--primary); color: #fff; }
.seg { display: inline-flex; padding: 4px; background: var(--bg); border-radius: 999px; gap: 2px; }
.seg button { display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font: inherit; font-weight: 600; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---------- template list + editor ---------- */
.tpl-name { color: var(--ink); font-weight: 650; }
.tpl-name:hover { color: var(--primary); }
.col-actions { width: 220px; text-align: right; white-space: nowrap; }
.col-actions .btn { margin-left: 6px; }
body.editor-screen .container { height: calc(100vh - 86px); padding-top: 16px; padding-bottom: 16px; display: flex; flex-direction: column; }
.editor-page { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.editor-bar { display: flex; align-items: center; gap: 10px; flex: none; }
.editor-bar .back-link { margin: 0; flex: none; }
.editor-input { height: 40px; min-width: 0; flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 0 16px; font: inherit; color: var(--ink); }
.editor-subject { flex: 1.4; }
.editor-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.studio { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 4fr) minmax(0, 3fr); gap: 16px; align-items: stretch; }
.studio-controls, .studio-editor { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line-2); border-radius: 18px; overflow: hidden; }
.controls-scroll { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px 16px; }
.col-kicker { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.design-kicker { padding: 12px 14px 0; }
.studio-controls .props { max-height: none; overflow: visible; border-top: 1px solid var(--line-2); margin-top: 14px; padding: 14px 0 0; grid-template-columns: 1fr; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line-2); background: #faf8f3; flex: none; }
.tool-gap { width: 8px; }
.swatch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.swatch input[type=color], .color-field input[type=color] { width: 36px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.block-tool { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: grab; }
.block-tool:hover { border-color: #cfd5f3; color: var(--primary); }
.canvas { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.canvas-card { min-height: 100%; border-radius: 16px; padding: 16px; box-shadow: var(--shadow-sm); }
.canvas-empty { padding: 40px 16px; text-align: center; color: var(--muted); border: 2px dashed #d9d1c0; border-radius: 14px; }
.block { display: flex; gap: 8px; align-items: flex-start; padding: 8px; margin: 0 0 8px; border: 2px solid transparent; border-radius: 12px; cursor: pointer; }
.block:hover { background: rgba(255,255,255,.45); }
.block.selected { border-color: var(--primary); background: rgba(255,255,255,.72); }
.handle { cursor: grab; color: var(--muted); font-weight: 700; letter-spacing: -1px; padding-top: 6px; user-select: none; }
.block-view { flex: 1; min-width: 0; pointer-events: none; }
.block-view h1, .block-view p { overflow-wrap: anywhere; }
.props { flex: none; max-height: 46%; overflow: auto; border-top: 1px solid var(--line-2); padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; background: #fff; }
.props-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.props-head strong { text-transform: capitalize; font-family: var(--serif); font-size: 18px; }
.props-empty { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.prop { display: flex; flex-direction: column; gap: 4px; }
.prop.wide { grid-column: 1 / -1; }
.prop input[type=range] { width: 100%; accent-color: var(--primary); }
.prop > span b { color: var(--ink-2); font-weight: 700; }
.prop > span { font-size: 12px; font-weight: 700; color: var(--muted); }
.prop input[type=text], .prop input[type=url], .prop textarea, .prop select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; color: var(--ink); background: #fff; }
.prop textarea { resize: vertical; min-height: 64px; }
.prop input:focus, .prop textarea:focus, .prop select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.color-field { display: flex; align-items: center; gap: 8px; }
.color-field input[type=text] { width: 96px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; font-family: var(--mono); }
.align { display: inline-flex; padding: 3px; background: var(--bg); border-radius: 999px; }
.align.wrap { flex-wrap: wrap; border-radius: 16px; }
.align button { border: 0; background: transparent; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; text-transform: capitalize; }
.align button.on { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }
.props .var-row { grid-column: 1 / -1; margin: 0; }
.var-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.chip { border: 1px dashed #c9c2ad; background: var(--bg); color: var(--primary); border-radius: 999px; padding: 3px 12px; font-family: var(--mono); font-size: 12.5px; cursor: pointer; }
.chip:hover { background: var(--primary-50); border-style: solid; }
.dirty { color: var(--warn); font-weight: 700; font-size: 13px; flex: none; }
.studio-preview { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 14px; background: linear-gradient(180deg, #fff, #faf8f3); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow-sm); }
.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; flex: none; }
.studio-preview .preview-bar { align-items: flex-start; }
.studio-preview .seg { flex-wrap: wrap; }
.stage { flex: 1; min-height: 0; overflow: auto; border-radius: 16px; background: repeating-linear-gradient(45deg, #f1ede2, #f1ede2 12px, #f4f0e6 12px, #f4f0e6 24px); padding: 22px 16px 36px; display: flex; gap: 22px; align-items: flex-start; justify-content: center; flex-wrap: nowrap; }
.dev-wrap { position: relative; flex: none; }
.dev-label { position: absolute; left: 0; right: 0; bottom: -22px; text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.dev { transform-origin: top left; background: #11131c; box-shadow: 0 20px 50px rgba(20, 26, 50, .28); position: absolute; top: 0; left: 0; overflow: hidden; }
.dev iframe { display: block; border: 0; background: #fff; width: 100%; }
.dev-phone { border-radius: 52px; padding: 14px; }
.dev-phone iframe { border-radius: 38px; }
.dev-phone::before { content: ""; position: absolute; top: 20px; left: 50%; width: 110px; height: 24px; border-radius: 14px; background: #11131c; transform: translateX(-50%); z-index: 2; }
.dev-tablet { border-radius: 38px; padding: 18px; }
.dev-tablet iframe { border-radius: 20px; }
.dev-desktop { border-radius: 18px; padding: 0; background: #2a2e3d; }
.dev-bar { height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 16px; }
.dev-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff6159; }
.dev-bar i:nth-child(2) { background: #ffbd2e; }
.dev-bar i:nth-child(3) { background: #28c940; }
.dev-bar span { margin-left: 14px; flex: 1; max-width: 420px; height: 22px; border-radius: 11px; background: #3a3f52; }
.dev-desktop iframe { border-radius: 0 0 18px 18px; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(24, 28, 48, .45); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: fade .18s ease; overflow: auto; }
.modal-top { z-index: 140; }
.modal-card { position: relative; background: #fff; border-radius: 28px; padding: 30px; width: 100%; box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2, .9, .3, 1.2); max-height: calc(100vh - 40px); overflow: auto; margin: auto; }
.modal-sm { max-width: 420px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 940px; }
.modal-card h2 { font-size: 26px; }
.modal-x { position: absolute; top: 18px; right: 18px; width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--bg); color: var(--ink-2); cursor: pointer; }
.modal-x:hover { background: var(--bg-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 30px 20px; border: 2px dashed #d3cbb6; border-radius: 22px; background: var(--bg); color: var(--muted); cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.dropzone strong { color: var(--ink); font-size: 16px; }
.dropzone.has-file { border-style: solid; border-color: var(--success); background: var(--success-50); }
.dz-ico { width: 54px; height: 54px; border-radius: 18px; background: #fff; display: grid; place-items: center; color: var(--primary); box-shadow: var(--shadow-sm); margin-bottom: 6px; }
.busy { text-align: center; padding: 40px 10px; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid var(--primary-50); border-top-color: var(--primary); margin: 0 auto 18px; animation: spin .8s linear infinite; }
.feedback { padding: 12px 14px; border-radius: 14px; background: var(--bg); font-size: 14px; margin-top: 4px; }
.feedback.ok { background: var(--success-50); color: #11704a; }
.feedback.err { background: var(--danger-50); color: #9c2f2f; }
.feedback ul { margin: 8px 0 0; padding-left: 18px; }

/* upload result */
.res-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.res-badge { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; background: var(--success-50); color: var(--success); flex: none; }
.res-badge.bad { background: var(--danger-50); color: var(--danger); }
.res-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.res-box { background: var(--bg); border-radius: 18px; padding: 14px; text-align: center; }
.res-box b { display: block; font-family: var(--serif); font-size: 26px; }
.res-box span { color: var(--muted); font-size: 12.5px; }
.res-box.good b { color: var(--success); }
.res-box.dup b { color: var(--warn); }
.res-box.bad b { color: var(--danger); }
details.removed { background: var(--bg); border-radius: 16px; padding: 12px 16px; margin-top: 8px; }
details.removed summary { cursor: pointer; font-weight: 600; }
.removed-list { max-height: 200px; overflow: auto; margin: 10px 0 0; padding: 0; list-style: none; font-size: 13.5px; }
.removed-list li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.removed-list li span:last-child { color: var(--danger); text-align: right; }

/* send wizard */
.stepper { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding-right: 50px; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.step i { font-style: normal; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-2); font-size: 13px; }
.step.active { color: var(--primary); }
.step.active i { background: var(--primary); color: #fff; }
.step.done i { background: var(--success); color: #fff; }
.step-line { flex: 1; min-width: 20px; height: 2px; background: var(--line); border-radius: 2px; }
.pick { display: grid; grid-template-columns: 250px 1fr; gap: 18px; margin-top: 16px; }
.pick-list { display: flex; flex-direction: column; gap: 8px; max-height: 440px; overflow: auto; padding: 2px; }
.pick-item { text-align: left; border: 2px solid var(--line-2); background: #fff; border-radius: 18px; padding: 14px 16px; font: inherit; cursor: pointer; color: var(--ink); transition: .15s; }
.pick-item:hover { border-color: #cfd5f3; }
.pick-item.active { border-color: var(--primary); background: var(--primary-50); }
.pick-item b { display: block; }
.pick-item small { color: var(--muted); display: block; margin-top: 2px; }
.pick-preview { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; min-height: 420px; background: #fff; }
.pick-subject { padding: 12px 18px; border-bottom: 1px solid var(--line-2); background: #faf8f2; font-weight: 600; font-size: 14px; min-height: 46px; }
.pick-preview iframe { flex: 1; width: 100%; border: 0; min-height: 380px; }
.recips { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow: auto; margin-top: 4px; }
.recip { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--line-2); border-radius: 16px; cursor: pointer; }
.recip:hover { background: #fcfbf7; }
.recip.on { border-color: #cfd5f3; background: var(--primary-50); }
.recip .grow { flex: 1; min-width: 0; }
.recip .grow b { display: block; }
.recip-total { margin-top: 14px; padding: 12px 16px; background: var(--bg); border-radius: 14px; font-weight: 600; }
.progress { height: 12px; background: var(--bg-2); border-radius: 999px; overflow: hidden; margin: 8px 0 14px; }
.progress-bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #5b6ee0); transition: width .4s ease; }
.progress-bar.done { background: linear-gradient(90deg, var(--success), #35c48d); }
.prog-line { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.send-log { list-style: none; margin: 14px 0 0; padding: 0; max-height: 280px; overflow: auto; border: 1px solid var(--line-2); border-radius: 16px; }
.send-log li { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.send-log li:last-child { border-bottom: 0; }
.send-log .ok { color: var(--success); }
.send-log .bad { color: var(--danger); }
.send-log .when { margin-left: auto; color: var(--muted); font-size: 12px; text-align: right; }
.send-log .err { color: var(--danger); font-size: 12.5px; }

/* toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow); animation: slide .25s ease; max-width: min(460px, 90vw); }
.toast.ok .ico { color: #66e0ae; }
.toast.err { background: #8a2b2b; }

/* ---------- sign-in page ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line-2); border-radius: 28px; padding: 34px 32px 30px; box-shadow: var(--shadow-lg); }
.login-card .brand { justify-content: center; margin-bottom: 18px; }
.login-card h1 { font-size: 27px; text-align: center; }
.login-card .sub { text-align: center; }
.login-card .field { margin-bottom: 14px; }
.login-btn { width: 100%; margin-top: 8px; }
.login-error { background: var(--danger-50); color: #9c2f2f; padding: 11px 14px; border-radius: 14px; font-size: 14px; margin-bottom: 14px; text-align: center; }
.btn-icon-only span { display: none; }
.btn-icon-only { padding: 0 13px; }

/* ---------- animations ---------- */
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes slide { from { opacity: 0; transform: translateY(10px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flash { 0%, 60% { background: #fff4cf; } 100% { background: transparent; } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  body.editor-screen .container { height: auto; display: block; }
  .editor-page { display: block; }
  .editor-bar { flex-wrap: wrap; }
  .studio { display: flex; flex-direction: column; height: auto; }
  .studio-controls, .studio-editor { min-height: 70vh; }
  .stage { min-height: 80vh; }
}
@media (max-width: 980px) {
  .topbar-inner { flex-wrap: wrap; border-radius: 28px; gap: 10px; }
  .search { order: 5; flex-basis: 100%; max-width: none; margin-left: 0; }
  .top-actions { margin-left: auto; }
  .nav-link span { display: none; }
  .nav-link { padding: 10px 12px; }
}
@media (max-width: 560px) {
  .brand-name { display: none; }
  .topbar { padding: 10px 10px 0; }
}
@media (max-width: 760px) {
  .container { padding: 20px 14px 60px; }
  .stats, .res-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .pick { grid-template-columns: 1fr; }
  .pick-list { flex-direction: row; overflow-x: auto; max-height: none; }
  .pick-item { min-width: 190px; }
  .hide-sm { display: none; }
  .cust-card { grid-template-columns: auto 1fr; }
  .cust-open { grid-column: 1 / -1; }
  .send-report li { grid-template-columns: 1fr; gap: 2px; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 0 14px; }
  .modal-card { padding: 22px; border-radius: 24px; }
  .filter input { width: 100%; }
  .filter { flex: 1; }
}
