:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #e3e6ee;
  --text: #1c2030;
  --muted: #6b7286;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --danger: #dc2626;
  --sidebar: #12172a;
  --sidebar-text: #c9cfe0;
  --sidebar-muted: #6f7894;
  --green: #16a34a;
  --amber: #d97706;
  --grey: #64748b;
  --red: #dc2626;
  --purple: #7c3aed;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  /* Chart series (validated for CVD separation and 3:1 contrast on --surface, light and dark). */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --chart-grid: #ecebe6;
  --chart-axis: #c3c2b7;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1220;
    --surface: #161b2e;
    --surface-2: #1d2338;
    --border: #2a3150;
    --text: #e6e9f2;
    --muted: #9198b0;
    --primary: #4f83ff;
    --sidebar: #0a0d18;
    --series-1: #3987e5;
    --series-2: #d95926;
    --chart-grid: #232a42;
    --chart-axis: #39415e;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1220;
  --surface: #161b2e;
  --surface-2: #1d2338;
  --border: #2a3150;
  --text: #e6e9f2;
  --muted: #9198b0;
  --primary: #4f83ff;
  --sidebar: #0a0d18;
  --series-1: #3987e5;
  --series-2: #d95926;
  --chart-grid: #232a42;
  --chart-axis: #39415e;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: 16px; margin: 0 0 12px; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.mt { margin-top: 24px; }

/* Layout */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar-collapsed .shell { grid-template-columns: 68px minmax(0, 1fr); }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 15px;
}
.sidebar .brand { color: #fff; }
.workspace-name { font-size: 12px; color: var(--sidebar-muted); margin: 6px 0 18px 40px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a, .nav-soon {
  padding: 7px 10px; border-radius: 7px; color: var(--sidebar-text); display: flex; align-items: center; gap: 11px;
}
.sidebar nav a .icon { flex: none; opacity: .8; }
.sidebar nav a.active .icon { opacity: 1; color: var(--primary); }
.icon { display: inline-block; vertical-align: middle; fill: currentColor; flex: none; }
/* Collapsed: icons only, names as tooltips */
.sidebar-collapsed .sidebar .label, .sidebar-collapsed .workspace-name, .sidebar-collapsed .workspace-switch { display: none; }
.sidebar-collapsed .sidebar nav a { justify-content: center; padding: 9px 0; }
.sidebar-collapsed .nav-group { height: 1px; margin: 10px 8px; overflow: hidden; background: rgba(255, 255, 255, .08); color: transparent; }
.sidebar-collapsed .brand { justify-content: center; margin-bottom: 18px; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.sidebar nav a.active { background: rgba(79, 131, 255, .18); color: #fff; }
.nav-soon { color: var(--sidebar-muted); cursor: default; }
.nav-soon small { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; opacity: .7; }
.nav-group {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted);
  margin: 16px 10px 4px;
}

.main-wrap { min-width: 0; display: flex; flex-direction: column; }
.main { padding: 24px 36px 48px; min-width: 0; }
/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; padding: 10px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid transparent; background: none; color: var(--text); cursor: pointer; list-style: none; }
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover, .icon-btn.active, details[open] > .icon-btn { background: var(--surface-2); border-color: var(--border); text-decoration: none; }
.bell-count { position: absolute; top: 2px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.top-search { display: flex; align-items: center; gap: 8px; width: min(420px, 100%); padding: 0 10px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); color: var(--muted); margin-left: 4px; }
.top-search input { border: 0; background: none; padding: 8px 0; outline: none; }
.top-search input:focus { outline: none; }
.top-search:focus-within { border-color: var(--primary); }
.top-search kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--muted); }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; padding: 6px; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(5, 8, 18, .22); }
.menu-panel a, .menu-panel button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0;
  border-radius: 8px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); text-decoration: none; }
.menu-title { padding: 6px 10px 8px; font-size: 12.5px; font-weight: 600; border-bottom: 1px solid var(--border); margin-bottom: 4px; overflow-wrap: anywhere; }
.menu-check { margin-left: auto; color: var(--primary); }
.account-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 10px; border: 1px solid var(--border); margin-left: 4px; }
.account-btn:hover, details[open] > .account-btn { background: var(--surface-2); }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; font-size: 13px; }
.account-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; }
.page-head .actions .btn .icon, .btn .icon { margin-right: 2px; }
/* Welcome tour */
.tour-layer { position: fixed; inset: 0; z-index: 100; background: rgba(5, 8, 18, .45); }
.tour-ring { position: fixed; border-radius: 12px; box-shadow: 0 0 0 3px var(--primary), 0 0 0 9999px rgba(5, 8, 18, .25); pointer-events: none; }
.tour-box { position: fixed; width: 320px; padding: 16px 18px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 16px 40px rgba(5, 8, 18, .3); }
.tour-center { display: grid; place-items: center; }
.tour-center .tour-box { position: static; width: min(420px, calc(100% - 32px)); }
.tour-box h3 { margin: 4px 0 6px; font-size: 16px; }
.tour-box p { margin: 0 0 14px; font-size: 14px; line-height: 1.55; white-space: pre-line; }
.tour-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* Support tickets, list switcher, warm-up */
.badge-ticket-open { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.badge-ticket-answered { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge-ticket-closed { background: var(--surface-2); color: var(--muted); }
.ticket-thread { display: flex; flex-direction: column; gap: 12px; max-width: 860px; }
.ticket-msg header { margin-bottom: 6px; }
.ticket-msg.from-staff { border-left: 3px solid var(--primary); }
.ticket-body p:last-child { margin-bottom: 0; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--text); }
.list-switch { float: right; margin-top: -4px; }
.list-switch .menu-panel { max-height: 360px; overflow-y: auto; }
form.inline { display: inline; }
.warmup-cell { min-width: 220px; }
.warmup-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-bottom: 4px; }
.warmup-bar span { display: block; height: 100%; background: var(--series-1, var(--primary)); border-radius: 4px; }
.spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 28px; }
.spark i { display: block; width: 6px; min-height: 2px; background: var(--series-1, var(--primary)); border-radius: 2px 2px 0 0; opacity: .85; }

/* User guide */
.guide-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; align-items: start; }
.guide-toc { position: sticky; top: 80px; display: flex; flex-direction: column; padding: 12px; max-height: calc(100vh - 100px); overflow-y: auto; }
.guide-toc a { padding: 4px 8px; border-radius: 6px; font-size: 13.5px; color: var(--text); }
.guide-toc a:hover { background: var(--surface-2); text-decoration: none; }
.guide-toc-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 12px 8px 4px; }
.guide-toc-group:first-child { margin-top: 2px; }
.guide-chapter { margin: 8px 0 12px; }
.guide-chapter:not(:first-child) { margin-top: 28px; }
.guide-section { scroll-margin-top: 80px; margin-bottom: 12px; }
.guide-section h3 { margin: 0 0 6px; }
.guide-section ul { margin: 0; padding-left: 20px; line-height: 1.6; }
.guide-section:target { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent); }
@media (max-width: 900px) { .guide-layout { grid-template-columns: 1fr; } .guide-toc { position: static; max-height: none; } }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13px; color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.card-flush { padding: 0; overflow-x: auto; }
.card:has(> .table) { overflow-x: auto; }
.card.narrow { max-width: 640px; }
.card.empty { text-align: center; padding: 48px 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.padded { padding: 14px 16px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card .stats { margin: 16px 0 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card .stat { background: var(--surface-2); border: 0; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }

.bar-row { display: grid; grid-template-columns: 130px 1fr 110px; gap: 12px; align-items: center; margin-bottom: 10px; }
.bar, .progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill, .progress-fill { height: 100%; background: var(--primary); border-radius: 99px; }
.progress { height: 10px; margin-bottom: 8px; }
.bar-num { text-align: right; font-variant-numeric: tabular-nums; }
.bar-subscribed { background: var(--green); }
.bar-unconfirmed { background: var(--amber); }
.bar-unsubscribed { background: var(--grey); }
.bar-blacklisted { background: var(--red); }
.bar-spam_reported { background: var(--purple); }

.row-link {
  display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.row-link:last-of-type { border-bottom: 0; }
.row-link:hover { text-decoration: none; color: var(--primary); }

/* Badges */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge-subscribed, .badge-job-done { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge-unconfirmed, .badge-job-queued, .badge-job-running, .badge-job-mapping { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.badge-blacklisted, .badge-job-failed { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.badge-spam_reported { background: color-mix(in srgb, var(--purple) 14%, transparent); color: var(--purple); }
.badge-camp-done, .badge-msg-sent { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge-camp-sending, .badge-camp-queued, .badge-camp-scheduled, .badge-msg-queued, .badge-msg-sending { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.badge-camp-paused, .badge-camp-awaiting, .badge-msg-skipped, .badge-msg-held { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.badge-camp-error, .badge-msg-failed { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.chip { display: inline-block; background: var(--surface-2); border-radius: 6px; padding: 1px 7px; font-size: 12px; margin: 0 4px 2px 0; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .check { width: 36px; padding-right: 0; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline; }

/* Tabs and toolbars */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }
.status-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.status-tabs a { padding: 5px 12px; border-radius: 99px; border: 1px solid var(--border); color: var(--text); background: var(--surface); font-size: 13px; }
.status-tabs a span { color: var(--muted); margin-left: 4px; }
.status-tabs a.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.status-tabs a.active span { color: inherit; opacity: .8; }
.status-tabs a:hover { text-decoration: none; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { max-width: 200px; }
.bulk-bar { display: flex; gap: 8px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.bulk-bar select, .bulk-bar input[type=text] { max-width: 220px; }
.pagination { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 8px; }

/* Forms */
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number],
input[type=url], input[type=tel], input[type=date], input[type=datetime-local], input[type=time],
input[type=file], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
.form .field { margin-bottom: 16px; }
.form label { display: block; font-weight: 600; margin-bottom: 5px; }
.field-check label { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.req { color: var(--danger); }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.help ul { margin: 4px 0 0; padding-left: 18px; }
.error, .form-errors { color: var(--danger); font-size: 13px; margin-top: 4px; }
.form-errors ul { margin: 0 0 12px; padding-left: 18px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; color: var(--text); background: transparent;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-ghost { background: var(--surface); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }

/* Messages */
.messages { margin-bottom: 16px; }
.message { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--border); }
.message-success { border-color: color-mix(in srgb, var(--green) 40%, var(--border)); background: color-mix(in srgb, var(--green) 8%, var(--surface)); }
.message-warning { border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); background: color-mix(in srgb, var(--amber) 8%, var(--surface)); }
.message-error { border-color: color-mix(in srgb, var(--red) 40%, var(--border)); background: color-mix(in srgb, var(--red) 8%, var(--surface)); }

/* Campaigns and sending */
.stat-small { font-size: 16px; }
.stat-inline { font-size: 22px; font-weight: 700; }
.summary { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; overflow-wrap: anywhere; }
.send-box { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.schedule-form { display: flex; gap: 8px; align-items: center; }
.schedule-form input { max-width: 240px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.preview-frame { width: 100%; height: 640px; border: 0; border-top: 1px solid var(--border); background: #fff; display: block; }
textarea.code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; line-height: 1.45; }
.merge-help summary { cursor: pointer; color: var(--primary); }
.merge-help code { display: inline-block; margin: 2px 0; }
.form ul, .form div:has(> label > input[type=checkbox]) { list-style: none; padding: 0; }
.form [id$="mail_lists"] label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.dns-head { display: flex; justify-content: space-between; align-items: center; }
.dns-grid { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 12px 0 0; }
.dns-grid dt { color: var(--muted); }
.dns-grid dd { margin: 0; min-width: 0; }
code.copy { cursor: copy; display: inline-block; max-width: 100%; }
code.wrap { white-space: pre-wrap; word-break: break-all; }
code.copied { outline: 2px solid var(--green); }

/* Reports and charts */
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stats-6 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-axis { stroke: var(--chart-axis); stroke-width: 1; }
.chart-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-crosshair { stroke: var(--chart-axis); stroke-width: 1; }
.chart-dot { stroke: var(--surface); stroke-width: 2; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.chart-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 140px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}
.chart-tooltip-title { color: var(--muted); margin-bottom: 4px; }
.chart-tooltip-row { display: flex; align-items: center; gap: 6px; }
.chart-tooltip-row strong { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.table-toggle { margin-top: 12px; }
.table-toggle summary { cursor: pointer; color: var(--primary); font-size: 13px; }
.table-toggle table { margin-top: 8px; }
.meter { height: 6px; background: var(--surface-2); border-radius: 99px; min-width: 80px; }
.meter-fill { height: 100%; background: var(--series-1); border-radius: 99px; }
.link-url { max-width: 520px; overflow-wrap: anywhere; }
.flags { display: flex; gap: 4px; flex-wrap: wrap; }

/* Segments */
.radio-row { display: flex; gap: 20px; flex-wrap: wrap; }
.radio-row label { font-weight: 400; display: flex; gap: 6px; align-items: center; }
.conditions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.condition-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) minmax(160px, 1.3fr) auto; gap: 8px; align-items: center; }
.value-days { display: flex; gap: 8px; align-items: center; }
.value-days input { max-width: 110px; }
.segment-count { border-top: 1px solid var(--border); padding: 14px 0 16px; margin-top: 4px; }
@media (max-width: 700px) { .condition-row { grid-template-columns: 1fr 1fr; } }

/* Templates and builder */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.template-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.template-thumb { display: block; height: 220px; overflow: hidden; background: #fff; border-bottom: 1px solid var(--border); position: relative; }
.template-thumb iframe { width: 640px; height: 760px; border: 0; transform: scale(.4); transform-origin: 0 0; pointer-events: none; position: absolute; top: 0; left: 0; }
.template-meta { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.template-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.template-actions form { display: inline; }
.starter-card { cursor: pointer; }
.starter-card:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
.starter-pick { display: flex; gap: 8px; align-items: center; }
.choice-list { max-width: 860px; }
.choice { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 18px 20px;
  border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.choice:last-child { border-bottom: 0; }
.choice:hover { background: var(--surface-2); text-decoration: none; }
.choice-icon { width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; font-weight: 700;
  background: color-mix(in srgb, var(--primary) 14%, var(--surface-2)); color: var(--primary); }
.choice-body { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.choice-body .muted { flex-basis: 100%; font-size: 13.5px; }
@media (max-width: 600px) { .choice { grid-template-columns: 44px minmax(0, 1fr); } .choice-icon { width: 44px; height: 44px; font-size: 16px; }
  .choice .btn { grid-column: 2; justify-self: start; } }
.builder { display: flex; flex-direction: column; gap: 10px; }
.builder-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.builder-bar input[type=text] { max-width: 320px; font-weight: 600; }
.builder-spacer { flex: 1; }
/* Wider block panel than GrapesJS's 15%, so block names fit. */
.builder .gjs-cv-canvas, .builder .gjs-pn-commands { width: 78%; }
.builder .gjs-pn-options { right: 22%; }
.builder .gjs-pn-views, .builder .gjs-pn-views-container { width: 22%; }
.builder .gjs-block { min-height: 84px; }
.builder .gjs-block-label { font-size: 11.5px; line-height: 1.3; }
.builder-canvas { height: calc(100vh - 190px); min-height: 520px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.form [id$="segments"] label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.template-picker { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.template-picker select { max-width: 280px; }

/* Automations */
.badge-auto-active, .badge-run-completed { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge-auto-paused, .badge-run-exited, .badge-run-skipped { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.badge-run-active { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.badge-run-failed { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.radio-col { display: flex; flex-direction: column; gap: 6px; }
.radio-col label { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.activate-form { display: flex; gap: 10px; align-items: center; }
.automation-layout { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 20px; align-items: start; }
.flow-head { display: flex; justify-content: space-between; align-items: baseline; }
.flow { overflow-x: auto; padding-bottom: 8px; }
.flow-start, .flow-end { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.flow-start { font-weight: 600; color: var(--text); background: var(--surface-2); border-radius: 99px; width: max-content; margin: 0 auto; padding: 4px 14px; }
.flow-seq { display: flex; flex-direction: column; align-items: center; min-width: 260px; }
.flow-add { display: flex; flex-direction: column; align-items: center; }
.flow-add::before, .flow-add::after { content: ""; width: 2px; height: 10px; background: var(--border); }
.flow-add-btn { width: 26px; height: 26px; border-radius: 50%; border: 1px dashed var(--muted); background: var(--surface); color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; }
.flow-add-btn:hover { border-style: solid; border-color: var(--primary); color: var(--primary); }
.flow-step { width: min(540px, 100%); background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 8px; padding: 10px 12px; }
.flow-wait { border-left-color: var(--amber); }
.flow-condition { border-left-color: var(--purple); }
.flow-add_tag, .flow-remove_tag, .flow-update_field, .flow-copy_to_list, .flow-move_to_list { border-left-color: var(--green); }
.flow-webhook { border-left-color: var(--grey); }
.flow-step-head { display: flex; gap: 8px; align-items: center; }
.flow-step-head strong { white-space: nowrap; }
.flow-spacer { flex: 1; }
.flow-icon { width: 22px; text-align: center; }
.flow-step-actions { display: flex; gap: 4px; }
.flow-step-summary { margin-top: 4px; overflow-wrap: anywhere; }
.flow-step-meta { margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flow-branches { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; margin-top: 10px; }
.flow-branch { border-top: 2px solid var(--border); padding-top: 6px; display: flex; flex-direction: column; align-items: center; }
.flow-yes { border-top-color: var(--green); }
.flow-no { border-top-color: var(--red); }
.flow-branch-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.step-dialog { border: 1px solid var(--border); border-radius: 12px; padding: 20px; width: min(460px, 92vw); background: var(--surface); color: var(--text); }
.step-dialog::backdrop { background: rgba(10, 14, 28, .5); }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.type-option { display: flex; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit; text-align: left; }
.type-option:hover:not([disabled]) { border-color: var(--primary); }
.type-option[disabled] { opacity: .45; cursor: not-allowed; }
.inline-fields { display: flex; gap: 8px; margin-bottom: 16px; }
.run-log { margin: 6px 0 0; padding-left: 18px; }
.automation-layout > * { min-width: 0; }
@media (max-width: 1000px) { .automation-layout { grid-template-columns: minmax(0, 1fr); } }

/* Cold email */
.form [id$="send_days"] { display: flex; gap: 12px; flex-wrap: wrap; }
.form [id$="send_days"] label { font-weight: 400; display: flex; gap: 6px; align-items: center; }
.presets { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.badge-contact-active { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.badge-contact-replied, .badge-contact-finished { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge-contact-bounced { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.badge-contact-unsubscribed, .badge-contact-stopped { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.badge-stage-interested, .badge-stage-meeting { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge-stage-not_interested { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.step-card { scroll-margin-top: 20px; }
.step-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.inbox-row { display: grid; grid-template-columns: 220px 1fr 150px; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.inbox-row:hover { background: var(--surface-2); text-decoration: none; }
.inbox-row.unread { border-left: 3px solid var(--primary); }
.inbox-row.unread .inbox-from strong { color: var(--primary); }
.inbox-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-meta { text-align: right; }
.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; max-width: 760px; }
.thread-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.thread-sent { border-style: dashed; margin-right: 15%; }
.thread-in { margin-right: 15%; }
.thread-out { margin-left: 15%; border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.thread-body { white-space: pre-wrap; font: inherit; margin: 8px 0 0; }
.stage-form { display: flex; gap: 6px; align-items: center; }
@media (max-width: 800px) { .inbox-row { grid-template-columns: 1fr; } .inbox-meta { text-align: left; } }

/* Sign-up forms */
.builder-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 460px); gap: 20px; align-items: start; }
.builder-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 0; }
.form-preview { background: repeating-conic-gradient(var(--surface-2) 0 25%, transparent 0 50%) 0 0 / 16px 16px; padding: 16px; }
.form-preview iframe { width: 100%; height: 520px; border: 0; background: transparent; display: block; }
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.color-grid input[type=color] { height: 38px; padding: 2px; }
.field-picker td, .field-picker th { padding: 6px 8px; }
.field-picker input[type=text] { padding: 5px 8px; }
.inline-check { display: flex !important; gap: 8px; align-items: center; font-weight: 400 !important; margin: 0 !important; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--border); }
code.snippet { display: block; padding: 10px 12px; margin: 6px 0 12px; border-radius: 8px; }
.public-card h1 { font-size: 22px; }
@media (max-width: 1100px) { .builder-layout { grid-template-columns: 1fr; } .builder-side { position: static; } }

/* Auth */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px; box-shadow: var(--shadow); }
.auth-brand { margin-bottom: 24px; }
.auth-card h1 { font-size: 20px; margin-bottom: 18px; }

@media (max-width: 900px) {
  .shell, .sidebar-collapsed .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 50; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 40px rgba(5, 8, 18, .4); }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-collapsed .sidebar .label, .sidebar-collapsed .workspace-name { display: revert; }
  .sidebar-collapsed .sidebar nav a { justify-content: flex-start; padding: 7px 10px; }
  .topbar { padding: 8px 12px; }
  .account-name, .top-search kbd { display: none; }
  .main { padding: 20px 16px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 80px; }
}

/* Inline bars in tables (top countries) */
.bar-col { width: 40%; }
.hbar { display: block; height: 8px; min-width: 4px; border-radius: 4px; background: var(--series-1); }

/* Card header with a control on the right, segmented period switch, activity feed */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented a { padding: 5px 12px; font-size: 13px; color: var(--muted); text-decoration: none; }
.segmented a + a { border-left: 1px solid var(--border); }
.segmented a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.activity-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: 0; }

/* Email verification results */
.badge-verify-deliverable, .bar-verify-deliverable { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge-verify-risky, .bar-verify-risky { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.badge-verify-undeliverable, .bar-verify-undeliverable { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.badge-verify-unknown, .badge-verify-unverified { background: var(--surface-2); color: var(--muted); }
.bar-verify-unknown, .bar-verify-unverified { background: var(--grey); }
.bar-fill.bar-verify-deliverable { background: var(--green); }
.bar-fill.bar-verify-risky { background: var(--amber); }
.bar-fill.bar-verify-undeliverable { background: var(--red); }
.inline-form { display: inline-flex; gap: 8px; align-items: center; }
.pre-line { white-space: pre-line; }

/* API docs */
.code-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-x: auto; white-space: pre; }
.docs h3 { font-size: 14px; margin-bottom: 6px; }
.docs .table td { vertical-align: top; }
ul.columns { columns: 2 220px; }

/* AI writing help */
.ai-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.ai-prompt { flex: 1 1 260px; min-width: 0; }
.ai-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ai-chip { cursor: pointer; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 13px; }
.ai-chip:hover { border-color: var(--primary); }
.ai-error { color: var(--danger); }

/* Sidebar: workspace switcher */
.workspace-switch summary { cursor: pointer; list-style: none; }
.workspace-switch summary::-webkit-details-marker { display: none; }
.workspace-switch form { margin: -10px 0 12px 40px; }
.workspace-switch .btn-link { color: var(--sidebar-text); font-size: 12px; padding: 2px 0; }
/* Roles editor */
.perm-group { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 10px; margin: 0 0 12px; }
.perm-group legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
.perm-group .check { display: block; font-size: 13px; padding: 3px 0; }
/* Notifications and search results */
.note-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.note-row.unread { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.note-row.unread .note-text::before { content: "●"; color: var(--primary); margin-right: 6px; font-size: 10px; }
.search-group h2 { margin-bottom: 6px; }
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

/* Files */
.upload-drop { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border-style: dashed; }
.upload-drop.dragging { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.asset { margin: 0; padding: 0; overflow: hidden; }
.asset-thumb { display: flex; align-items: center; justify-content: center; height: 140px; background: var(--surface-2); }
.asset-thumb img { max-width: 100%; max-height: 140px; object-fit: contain; }
.asset-doc { font-weight: 700; color: var(--muted); font-size: 20px; }
.asset figcaption { padding: 10px 12px; }
.asset-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-actions { display: flex; gap: 6px; margin-top: 6px; }

/* Leads and proposals */
.badge-tier-high { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge-tier-good { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.badge-tier-average { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.badge-tier-low { background: var(--surface-2); color: var(--muted); }
.badge-proposal-draft, .badge-proposal-ready { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.badge-proposal-sent, .badge-proposal-viewed { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.badge-proposal-accepted { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge-proposal-declined { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.notice { margin-top: 16px; max-width: 900px; }

/* Orders */
.badge-order-paid { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge-order-pending { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.badge-order-partial, .badge-order-expired { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.badge-order-refunded { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }

/* Mailbox sign-in, inbox tools */
.signin-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.signin-buttons form { margin: 0; }
.thread-tools { margin-top: 16px; }

/* Billing */
.usage-row { margin: 0 0 12px; }
.usage-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.meter-fill.meter-warn { background: var(--amber); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.plan-card { margin: 0; display: flex; flex-direction: column; }
.plan-card form, .plan-card > .badge { margin-top: auto; }
.plan-current { border-color: var(--primary); }
.plan-price { font-size: 22px; font-weight: 700; margin: 8px 0; }
.plan-limits { padding-left: 18px; margin: 0 0 16px; }
.badge-billing-trialing { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.badge-billing-past_due, .badge-billing-canceled { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }

/* Sequence email versions (A/Z tests) */
.step-version { border-left: 3px solid var(--border); padding: 4px 0 4px 14px; margin: 0 0 14px; }
.step-version:target { border-left-color: var(--primary); }
.version-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.version-head .btn .icon, .version-lead .icon, .version-verdict .icon, .step-card .form-actions .btn .icon { vertical-align: -3px; }
.version-tag { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 6px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 13px; }
.version-results { overflow-x: auto; }
.version-results .table { min-width: 640px; }
.version-table tr.is-leader td { background: color-mix(in srgb, var(--green) 8%, transparent); }
.version-table tr.is-leader .version-tag { background: var(--green); color: #fff; }
.version-table tr.version-total td { border-top: 2px solid var(--border); }
.version-lead { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.version-verdict { display: flex; flex-direction: column; gap: 4px; }

/* Campaign report: insights, delivery funnel, world map.
   Map colours run from --map-low to --map-high (one hue); in dark mode the scale flips so more = brighter. */
:root { --map-empty: #e6e8ee; --map-low: #d7e6f8; --map-high: #164f97; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --map-empty: #252c44; --map-low: #1d3354; --map-high: #8cbdf7; }
}
:root[data-theme="dark"] { --map-empty: #252c44; --map-low: #1d3354; --map-high: #8cbdf7; }
.insight-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.insight { position: relative; padding-left: 18px; }
.insight::before {
  content: ""; position: absolute; left: 0; top: .55em; width: 8px; height: 8px; border-radius: 50%; background: var(--series-1);
}
.insight-good::before { background: var(--green); }
.insight-bad::before { background: var(--red); }
.insight-warning::before { background: var(--amber); }
.insight-note { margin: 14px 0 0; }
.chart-label { fill: var(--text); font-size: 12px; }
.chart-value { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-track { fill: var(--surface-2); }
.world-map { position: relative; padding: 0 16px 14px; }
.world-map svg { display: block; max-width: 100%; height: auto; }
.map-country { fill: var(--map-empty); stroke: var(--surface); stroke-width: .5; }
.map-country:focus { outline: none; }
.map-outline { fill: none; stroke: var(--text); stroke-width: 1.5; pointer-events: none; }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.map-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--map-empty); }
.map-scale { width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(to right, var(--map-low), var(--map-high)); }
.map-scale-end { font-variant-numeric: tabular-nums; }
.map-legend > .map-scale-end:nth-child(3) { margin-left: 10px; }

/* Template categories and gallery filter chips */
.gallery-filter { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.gallery-filter[hidden] { display: none; }
.gallery-filter button { padding: 5px 12px; border-radius: 99px; border: 1px solid var(--border); color: var(--text); background: var(--surface);
  font: inherit; font-size: 13px; cursor: pointer; }
.gallery-filter button span { color: var(--muted); margin-left: 4px; }
.gallery-filter button:hover { border-color: var(--primary); }
.gallery-filter button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.gallery-filter button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.gallery-filter button[aria-pressed="true"] span { color: inherit; opacity: .8; }
.template-card[hidden] { display: none; }
.template-category { align-self: flex-start; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }

/* Workflow editor: moving steps (drag handle, up / down, drop places) */
.flow-drag {
  display: inline-grid; place-items: center; min-width: 26px; min-height: 26px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 16px; line-height: 1; cursor: grab; touch-action: none;
}
.flow-drag:hover { background: var(--surface-2); color: var(--text); }
.flow-drag:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.flow-step-actions { flex-wrap: wrap; justify-content: flex-end; }
.flow-move-btn { padding-inline: 8px; }
.flow-add { position: relative; }
.flow-drop-mark {
  display: none; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 220px; height: 3px; border-radius: 99px; background: var(--primary); pointer-events: none;
  align-items: center; justify-content: center;
}
.flow-drop-mark span {
  padding: 2px 10px; border-radius: 99px; background: var(--primary); color: var(--primary-ink);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.flow.is-arranging { user-select: none; -webkit-user-select: none; }
.flow.is-arranging .flow-add.can-drop .flow-add-btn {
  border-style: solid; border-color: var(--primary); color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}
.flow.is-arranging .flow-add:not(.can-drop) .flow-add-btn { opacity: .3; }
.flow-add.is-target .flow-add-btn { visibility: hidden; }
.flow-add.is-target .flow-drop-mark { display: flex; }
.flow .is-moving { opacity: .4; }
.flow-step.is-moving { outline: 2px dashed var(--primary); outline-offset: 2px; }
.flow-ghost {
  position: fixed; left: 0; top: 0; z-index: 1000; margin: 0; pointer-events: none; opacity: .92;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .22); cursor: grabbing;
}
@media (pointer: coarse) {
  .flow-drag { min-width: 36px; min-height: 36px; font-size: 20px; }
}
