/* =====================================================================
   Shared admin design system — used by superadmin/ and app/ panels.
   Mobile-first, no external CSS framework.
   ===================================================================== */

:root {
  /* Monochrome "paper" palette — black/white/gray chrome, with small
     semantic-color accents kept only where a status genuinely needs to be
     told apart at a glance (success/warning/danger/info badges). */
  --lf-primary: #111827;
  --lf-primary-dark: #000000;
  --lf-primary-light: #f3f4f6;
  --lf-bg: #fafafa;
  --lf-surface: #ffffff;
  --lf-border: #e5e5e5;
  --lf-text: #111111;
  --lf-text-muted: #6b6b6b;
  --lf-success: #15803d;
  --lf-success-bg: #f0f0f0;
  --lf-warning: #92400e;
  --lf-warning-bg: #f5f5f4;
  --lf-danger: #b91c1c;
  --lf-danger-bg: #f5f5f5;
  --lf-info: #111827;
  --lf-info-bg: #f0f0f0;
  --lf-radius: 8px;
  --lf-radius-lg: 14px;
  /* One shared height scale for every control that sits in a row next to
     another — text inputs, selects, color pickers, regular/small buttons.
     Padding+font-size alone don't guarantee two different native controls
     (a text <input> vs a browser's own color-swatch <input type="color">
     chrome, for instance) compute to the same rendered height, so the
     height is pinned explicitly instead of left to add up on its own. */
  --lf-control-h: 42px;
  --lf-control-h-sm: 34px;
  --lf-shadow: 0 1px 2px rgba(17,17,17,.03), 0 4px 16px rgba(17,17,17,.05);
  --lf-shadow-hover: 0 2px 4px rgba(17,17,17,.04), 0 10px 28px rgba(17,17,17,.09);
  --lf-sidebar-w: 240px;
  --lf-topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--lf-bg);
  color: var(--lf-text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--lf-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; }
p { margin: 0 0 12px; }

/* ---------- Layout: sidebar + topbar shell ---------- */
.lf-shell { display: flex; min-height: 100vh; }
.lf-sidebar {
  width: var(--lf-sidebar-w);
  background: #111827;
  color: #d1d5db;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 40;
  transition: transform .2s ease;
}
/* Same abstract dot-grid + ring motif as the login/signup side panel,
   carried through to the logged-in shell so the two feel like one product. */
.lf-sidebar::before, .lf-sidebar::after {
  content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.1); pointer-events: none;
}
.lf-sidebar::before { width: 260px; height: 260px; right: -140px; top: -80px; }
.lf-sidebar::after { width: 200px; height: 200px; left: -110px; bottom: 40px; border-color: rgba(255,255,255,.07); }
.lf-sidebar-dots {
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.1) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(circle at 25% 20%, #000 0%, transparent 60%);
  mask-image: radial-gradient(circle at 25% 20%, #000 0%, transparent 60%);
}
.lf-sidebar-ring {
  position: absolute; width: 130px; height: 130px; border-radius: 50%; pointer-events: none;
  border: 1px dashed rgba(255,255,255,.12); right: 8%; bottom: 14%;
}
.lf-sidebar-brand {
  position: relative; z-index: 1;
  padding: 16px 20px; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.lf-sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lf-sidebar-brand-main { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: hidden; }
.lf-sidebar-mark { display: inline-flex; flex-shrink: 0; }
/* Name + workspace stack beside the (now bigger) mark instead of the
   workspace line running full-width underneath everything — product name
   is still always the primary label, the current workspace (an agency's
   name, or "Super Admin") secondary underneath it, just closer together. */
.lf-sidebar-brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow: hidden; }
.lf-sidebar-brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lf-sidebar-context {
  font-size: 12px; font-weight: 600; color: rgba(255,255,255,.55); margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Only the standalone case (a custom-uploaded logo, sitting below the row
   full-width rather than in .lf-sidebar-brand-text beside a mark) needs
   its own top spacing. */
.lf-sidebar-brand > .lf-sidebar-context { margin-top: 8px; }
.lf-sidebar-brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--lf-primary); }
.lf-nav { position: relative; z-index: 1; padding: 12px; }
.lf-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: #d1d5db;
  font-size: 14px; font-weight: 500; margin-bottom: 2px;
  transition: background .12s ease, color .12s ease;
}
.lf-nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.lf-nav a.active { background: #fff; color: #111827; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.lf-nav .lf-nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; padding: 16px 12px 6px; }
.lf-nav-icon { display: inline-flex; width: 18px; justify-content: center; }

.lf-main { flex: 1; margin-left: var(--lf-sidebar-w); min-width: 0; background: var(--lf-bg); }
.lf-topbar {
  height: var(--lf-topbar-h); background: rgba(255,255,255,.85); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--lf-border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
  position: sticky; top: 0; z-index: 30;
}
.lf-topbar-title { font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.lf-topbar-right { display: flex; align-items: center; gap: 14px; }
.lf-topbar-userinfo { display: flex; flex-direction: column; line-height: 1.25; }
.lf-topbar-userinfo .name { font-size: 13px; font-weight: 700; color: var(--lf-text); }
.lf-topbar-userinfo .role { font-size: 11px; color: var(--lf-text-muted); }
/* Superadmin-impersonating-an-agency notice — one icon in the topbar
   (was a full alert row, then a text pill; a single click-to-return icon
   with a tooltip carries the same info without spending any real estate
   on it while it's not being read). */
.lf-impersonate-btn { background: var(--lf-warning-bg); color: var(--lf-warning); font-size: 15px; }
.lf-impersonate-btn:hover { background: var(--lf-warning-bg); color: var(--lf-warning); filter: brightness(.92); }
.lf-hamburger { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--lf-text); }
.lf-content { padding: 20px; max-width: 1200px; }
.lf-sidebar-overlay { display: none; }

@media (max-width: 900px) {
  .lf-sidebar { transform: translateX(-100%); }
  .lf-sidebar.open { transform: translateX(0); }
  .lf-main { margin-left: 0; }
  .lf-hamburger { display: inline-block; }
  .lf-sidebar-overlay.open {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39;
  }
  .lf-content { padding: 14px; }
}

/* ---------- Collapsed (icon-only) sidebar ---------- */
.lf-sidebar-collapse-btn {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255,255,255,.12); flex-shrink: 0;
  background: rgba(255,255,255,.08); color: #d1d5db; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 12px; padding: 0; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: background .12s ease, color .12s ease, transform .15s ease;
}
.lf-sidebar-collapse-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.lf-shell.sidebar-collapsed { --lf-sidebar-w: 68px; }
.lf-shell.sidebar-collapsed .lf-sidebar-collapse-btn { transform: rotate(180deg); }
.lf-shell.sidebar-collapsed .lf-sidebar-brand { padding: 14px 8px; }
.lf-shell.sidebar-collapsed .lf-sidebar-brand-row { flex-direction: column; gap: 10px; }
.lf-shell.sidebar-collapsed .lf-sidebar-brand-main { justify-content: center; }
.lf-shell.sidebar-collapsed .lf-sidebar-brand-text,
.lf-shell.sidebar-collapsed .lf-sidebar-context,
.lf-shell.sidebar-collapsed .lf-nav-label,
.lf-shell.sidebar-collapsed .lf-nav-section { display: none; }
.lf-shell.sidebar-collapsed .lf-nav a { justify-content: center; padding-left: 0; padding-right: 0; }
.lf-shell.sidebar-collapsed .lf-nav a:hover::after,
.lf-shell.sidebar-collapsed .lf-nav a:focus-visible::after {
  content: attr(data-label); position: absolute; left: 100%; margin-left: 10px; top: 50%; transform: translateY(-50%);
  background: #111827; color: #fff; font-size: 12.5px; font-weight: 600; padding: 6px 10px; border-radius: 6px;
  white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 5; pointer-events: none;
}
.lf-shell.sidebar-collapsed .lf-nav a { position: relative; }
/* .lf-content's own max-width is a fixed 1200px regardless of sidebar
   state — collapsing the sidebar frees up ~172px, but nothing was ever
   using it, so every page's content just sat the same width with empty
   space on the right instead of actually getting bigger. */
.lf-shell.sidebar-collapsed .lf-content { max-width: none; }
@media (max-width: 900px) { .lf-shell.sidebar-collapsed { --lf-sidebar-w: 240px; } .lf-sidebar-collapse-btn { display: none; } }

/* ---------- Focus mode (Form Builder only — hide just the sidebar for a
   bigger canvas; the topbar/header stays visible so the page title, save
   status, and account controls are never out of reach). ---------- */
.lf-shell.focus-mode .lf-sidebar { display: none; }
.lf-shell.focus-mode .lf-main { margin-left: 0; }
.lf-shell.focus-mode .lf-content { max-width: none; padding: 16px 20px; }

/* ---------- Buttons ---------- */
.lf-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--lf-control-h); padding: 0 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; background: var(--lf-surface);
  color: var(--lf-text); text-decoration: none; line-height: 1.2; box-sizing: border-box;
  transition: background .12s ease, border-color .12s ease, transform .12s ease, box-shadow .12s ease;
  white-space: nowrap; flex-shrink: 0; /* never wrap or get squeezed inside a flex row next to longer sibling text */
}
.lf-btn:hover { text-decoration: none; }
.lf-btn-primary { background: var(--lf-primary); color: #fff; box-shadow: 0 1px 2px rgba(17,17,17,.08); }
.lf-btn-primary:hover { background: var(--lf-primary-dark); box-shadow: 0 4px 10px rgba(17,17,17,.18); transform: translateY(-1px); }
.lf-btn-primary:active { transform: translateY(0); }
.lf-btn-outline { border-color: var(--lf-border); background: var(--lf-surface); color: var(--lf-text); }
.lf-btn-outline:hover { background: var(--lf-bg); border-color: #d4d4d4; }
.lf-btn-danger { background: var(--lf-danger); color: #fff; }
.lf-btn-sm { height: var(--lf-control-h-sm); padding: 0 12px; font-size: 13px; }
.lf-btn-block { width: 100%; }
.lf-btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Cards / grid ---------- */
.lf-card { background: var(--lf-surface); border: 1px solid var(--lf-border); border-radius: var(--lf-radius-lg); box-shadow: var(--lf-shadow); padding: 20px; transition: box-shadow .15s ease, border-color .15s ease, transform .15s ease; }
.lf-card-link { display: block; text-decoration: none; color: inherit; }
.lf-card-link:hover, .lf-card-hover:hover { box-shadow: var(--lf-shadow-hover); border-color: #d8d8d8; transform: translateY(-2px); text-decoration: none; }
.lf-grid { display: grid; gap: 16px; }
.lf-grid-2 { grid-template-columns: repeat(2, 1fr); }
.lf-grid-3 { grid-template-columns: repeat(3, 1fr); }
.lf-grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .lf-grid-3, .lf-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .lf-grid-2, .lf-grid-3, .lf-grid-4 { grid-template-columns: 1fr; } }
/* Grid items default to min-width:auto, i.e. "never shrink below my content's
   own minimum" — so a wide child (a .lf-table-wrap holding a .lf-table with
   its min-width:560px, say) silently forces its whole grid track, and with
   it the page, wider than the viewport instead of scrolling internally the
   way .lf-table-wrap's own overflow-x:auto intends. min-width:0 here is
   what actually lets that internal scroll take over. (analytics.php's
   "By UTM source"/"By device" two-up tables is what surfaced this.) */
.lf-grid > * { min-width: 0; }

.lf-stat { display: flex; flex-direction: column; gap: 10px; }
.lf-stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.lf-stat-icon {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--lf-primary-light); color: var(--lf-primary); font-size: 16px;
}
.lf-stat-label { font-size: 12px; color: var(--lf-text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.lf-stat-value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.lf-stat-sub { font-size: 12px; color: var(--lf-text-muted); }
.lf-stat-trend { font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.lf-stat-trend.up { color: var(--lf-success); }
.lf-stat-trend.down { color: var(--lf-danger); }

/* ---------- Forms (admin, not public lead-forms) ---------- */
.lf-form-group { margin-bottom: 16px; }
.lf-form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--lf-text); }
/* Small muted note/explainer text — e.g. "Pixel ID and access token come
   from Meta Events Manager…" under a field or section. .hint and .lf-help
   are the same style under two names (grown up in different corners of the
   app); kept both selectors so neither call site needs renaming, but they
   must never drift apart again. Standalone (not scoped to .lf-form-group)
   so it renders correctly wherever it's dropped — a bare <p class="hint">
   between fields used to render as plain full-size body text because this
   rule only fired inside a .lf-form-group ancestor. */
.hint, .lf-help { font-size: 12.5px; color: var(--lf-text-muted); line-height: 1.5; margin-top: 4px; }
.lf-input, .lf-select, .lf-textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--lf-border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--lf-text); box-sizing: border-box;
}
.lf-input:focus, .lf-select:focus, .lf-textarea:focus { outline: none; border-color: var(--lf-primary); box-shadow: 0 0 0 3px var(--lf-primary-light); }
.lf-input, .lf-select { height: var(--lf-control-h); }
.lf-textarea { resize: vertical; min-height: 90px; }
/* One dropdown arrow for the whole portal. The browser's own arrow sits hard
   against the right border and ignores padding, so draw an inset one. The
   selector is on the element so classless and third-party selects match too;
   padding-right is !important so inline "padding:" shorthands can't undo it.
   Mirrored in public-form.css. */
select:not([multiple]):not([size]) {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 7.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 14px 14px;
  padding-right: 36px !important; text-overflow: ellipsis;
}
/* Portal-wide JS form validation (assets/js/admin.js) — replaces the
   browser's own native "Please fill in this field" bubble with this inline
   style, everywhere, instead of each page inventing its own. */
.lf-input.is-invalid, .lf-select.is-invalid, .lf-textarea.is-invalid { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220,38,38,.12) !important; }
.lf-field-error-msg { font-size: 12px; color: #dc2626; margin-top: 5px; }

/* ---------- Page Builder rich-text fields ----------
   The toolbar only takes up real space while the field it belongs to is
   actually being worked on — with 15-20+ of these on one panel, all their
   toolbars sitting open at once made the page unusably tall. Driven by
   :focus-within (not a JS focus/blur listener on just the editable div),
   so clicking one of the toolbar's OWN controls — the font/size dropdown,
   a color swatch — never counts as "clicking away" and closes it out from
   under you; it stays open the whole time anything inside is focused.
   display:none/flex (not a max-height cap) — a max-height animation here
   previously clipped the toolbar to invisible whenever it wrapped onto a
   second row in a narrow sidebar column, which is most of the time with 8
   controls in it. A quick fade+slide keyframe on reveal keeps it from
   feeling like an abrupt snap without that risk. */
.lf-rich-toolbar {
  display: none; gap: 3px; flex-wrap: wrap; align-items: center; margin-bottom: 6px;
  padding: 4px; background: var(--lf-bg); border: 1px solid var(--lf-border); border-radius: 8px;
}
.lf-rich-field:focus-within .lf-rich-toolbar { display: flex; animation: lfRichToolbarIn .15s ease; }
@keyframes lfRichToolbarIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.lf-rich-toolbar-btn, .lf-rich-toolbar-select, .lf-rich-toolbar-swatch {
  height: 26px; box-sizing: border-box; border: 1px solid var(--lf-border); border-radius: 6px;
  background: #fff; color: var(--lf-text); cursor: pointer; flex-shrink: 0;
}
.lf-rich-toolbar-btn {
  width: 26px; padding: 0; font-size: 13px; display: inline-flex; align-items: center; justify-content: center;
}
.lf-rich-toolbar-btn:hover { background: var(--lf-bg); border-color: #d4d4d4; }
.lf-rich-toolbar-select { padding: 0 4px; font-size: 11.5px; width: auto; max-width: 88px; }
/* The editor toolbar's tiny dropdowns need a smaller arrow than the portal default. */
select.lf-rich-toolbar-select:not([multiple]):not([size]) { background-position: right 6px center; background-size: 10px 10px; padding-left: 6px; padding-right: 20px !important; }
.lf-rich-toolbar-swatch { width: 26px; padding: 2px; }
.lf-rich-toolbar-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.lf-rich-toolbar-swatch::-webkit-color-swatch { border: none; border-radius: 4px; }
.lf-rich-toolbar-swatch::-moz-color-swatch { border: none; border-radius: 4px; }
.lf-rich-toolbar-sep { width: 1px; height: 18px; background: var(--lf-border); margin: 0 2px; flex-shrink: 0; }
.lf-rich-editable {
  height: auto; min-height: 38px; max-height: 260px; overflow-y: auto; line-height: 1.5; cursor: text; padding: 8px 10px;
  transition: border-color .12s ease;
}
.lf-rich-editable:focus { border-color: var(--lf-primary); box-shadow: 0 0 0 3px var(--lf-primary-light); outline: none; }
.lf-rich-editable-tall { min-height: 90px; }
.lf-rich-editable:empty::before { content: attr(data-placeholder); color: var(--lf-text-muted); pointer-events: none; }
.lf-rich-editable b, .lf-rich-editable strong { font-weight: 700; }
.lf-rich-editable i, .lf-rich-editable em { font-style: italic; }
.lf-rich-editable u { text-decoration: underline; }
/* Native browser chrome (the color-swatch UI in <input type="color">) has
   its own internal box model that text-input padding doesn't reach, so a
   plain .lf-input height alone still renders shorter/differently next to
   a real text <input> in the same row — pin it explicitly and trim the
   padding so the swatch itself fills the control. */
input[type="color"].lf-input { height: var(--lf-control-h); padding: 4px 6px; cursor: pointer; }
input[type="color"].lf-input::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"].lf-input::-webkit-color-swatch { border: none; border-radius: 4px; }
input[type="color"].lf-input::-moz-color-swatch { border: none; border-radius: 4px; }
/* Every native color swatch gets a paired hex text field beside it
   (assets/js/admin.js wireColorHexInput()) — a bare swatch only opens the
   browser's own RGB-slider picker, with no way to type or paste an exact
   brand hex. The swatch shrinks to a fixed width here (its containing
   .lf-form-group would otherwise stretch it to fill the whole row, leaving
   no room for the hex field next to it) and the hex field takes the rest. */
.lf-color-hex-wrap { display: flex; align-items: center; gap: 8px; }
.lf-color-hex-wrap input[type="color"].lf-input { width: 44px; flex-shrink: 0; padding: 0; }
.lf-color-hex-input { flex: 1; min-width: 90px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }

/* Styled file picker (assets/js/admin.js wireFileInput()), portal-wide —
   the real <input type=file> stays functional (clipped off-screen, not
   display:none, so it's still focusable/tabbable) behind a real button and
   filename readout, with a dashed drop-zone box replacing the plain
   .lf-input border a bare file input used to draw around the OS's own
   plain "Choose file" control. */
.lf-file-wrap {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1.5px dashed var(--lf-border); border-radius: var(--lf-radius); padding: 9px 12px;
  transition: border-color .15s ease, background .15s ease;
}
.lf-file-wrap.is-dragover { border-color: var(--lf-primary); background: var(--lf-primary-light); border-style: solid; }
.lf-file-native {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.lf-file-btn { flex-shrink: 0; }
.lf-file-name { font-size: 13px; color: var(--lf-text-muted); overflow-wrap: anywhere; }
.lf-file-name.has-file { color: var(--lf-text); font-weight: 600; }
/* flex-start, not flex-end — with every field across the portal now able to
   grow a validation error message underneath it (assets/js/admin.js), a
   bottom-aligned row meant one field failing validation visibly shoved
   every *other* field in that same row down to keep sharing a bottom edge
   with it — their labels and inputs literally shifting position as you
   typed, not just the failing field's own space growing. Top-aligning
   means a row's fields only ever move if their own label/input needs
   more room, never because a sibling grew. */
.lf-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.lf-row > * { flex: 1; min-width: 180px; }
/* A button dropped into a .lf-row (next to an input/select it acts on)
   must never stretch to match the input's width — .lf-row > * { flex:1 }
   was doing exactly that everywhere a "Save"-style button sat inline next
   to a field, which is what made the Custom URL button balloon to match
   the input box. Every .lf-btn keeps its natural, consistent size instead. */
.lf-row > .lf-btn { flex: 0 0 auto; min-width: 0; }

/* ---------- Tables ---------- */
.lf-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.lf-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.lf-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--lf-text-muted); border-bottom: 1px solid var(--lf-border); padding: 9px 12px; white-space: nowrap; }
.lf-table td { padding: 13px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.lf-table tr:last-child td { border-bottom: 0; }
.lf-table tr:hover td { background: var(--lf-bg); }
.lf-table-name { display: flex; align-items: center; gap: 10px; }

/* Narrow key/value tables (order summaries, receipts) — no forced min-width,
   so they never need horizontal scroll even on small phones. */
.lf-table-compact { min-width: 0; width: 100%; table-layout: fixed; }
.lf-table-compact th { white-space: normal; width: 55%; }
.lf-table-compact td { text-align: right; word-break: break-word; }

/* ---------- Badges / pills ---------- */
.lf-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.lf-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.lf-badge-success { background: var(--lf-success-bg); color: var(--lf-success); }
.lf-badge-warning { background: var(--lf-warning-bg); color: var(--lf-warning); }
.lf-badge-danger { background: var(--lf-danger-bg); color: var(--lf-danger); }
.lf-badge-info { background: var(--lf-info-bg); color: var(--lf-info); }
.lf-badge-muted { background: #f3f4f6; color: var(--lf-text-muted); }

/* Google-Analytics-style date range picker — one shared control (a button
   showing the current range + a dual-pane dropdown: presets on the left,
   a real calendar grid on the right, same shape as most SaaS date pickers)
   instead of every filter form rolling its own bare From/To date pair.
   See assets/js/admin.js wireDateRangePicker(). The trigger is styled to
   the exact same height/border/radius as .lf-input/.lf-select (not .lf-btn
   — .lf-btn-sm's 34px made it visibly shorter than every field next to it
   in the same filter row) so it reads as one more field in the row, not an
   oddly-sized button. */
.lf-daterange { position: relative; display: inline-block; width: 100%; }
.lf-daterange-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%; height: var(--lf-control-h);
  padding: 0 12px; border: 1px solid var(--lf-border); border-radius: var(--lf-radius);
  background: #fff; color: var(--lf-text); font-size: 14px; font-family: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: border-color .12s ease;
}
.lf-daterange-trigger:hover { border-color: #d4d4d4; }
.lf-daterange-trigger:focus-visible { outline: none; border-color: var(--lf-primary); box-shadow: 0 0 0 3px var(--lf-primary-light); }
.lf-daterange-trigger .bi-calendar3 { color: var(--lf-text-muted); font-size: 15px; flex-shrink: 0; }
.lf-daterange-label { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.lf-daterange-chevron { color: var(--lf-text-muted); font-size: 10px; flex-shrink: 0; transition: transform .15s ease; }
.lf-daterange.is-open .lf-daterange-chevron { transform: rotate(180deg); }

.lf-daterange-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20;
  display: flex; background: var(--lf-surface); border: 1px solid var(--lf-border); border-radius: var(--lf-radius-lg);
  box-shadow: var(--lf-shadow-hover); overflow: hidden;
}
.lf-daterange-presets { width: 150px; flex-shrink: 0; padding: 8px; border-right: 1px solid var(--lf-border); }
.lf-daterange-preset {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 7px;
  padding: 8px 10px; margin-bottom: 1px; font-size: 13.5px; color: var(--lf-text); cursor: pointer; font-family: inherit;
}
.lf-daterange-preset:hover { background: var(--lf-bg); }
.lf-daterange-preset:focus-visible { outline: none; background: var(--lf-primary-light); }
.lf-daterange-preset.active { background: var(--lf-primary-light); font-weight: 600; color: var(--lf-primary); }

.lf-daterange-calendar { width: 290px; flex-shrink: 0; padding: 14px 16px 12px; }
.lf-daterange-tabs { display: flex; gap: 20px; margin-bottom: 14px; }
.lf-daterange-tab {
  background: none; border: 0; border-bottom: 2px solid var(--lf-border); cursor: pointer; font-family: inherit;
  padding: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--lf-text-muted);
}
.lf-daterange-tab .lf-daterange-tab-value { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: normal; text-transform: none; color: var(--lf-text); margin-top: 3px; }
.lf-daterange-tab.active { border-bottom-color: var(--lf-primary); color: var(--lf-primary); }
.lf-daterange-month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.lf-daterange-month-nav button { background: none; border: 0; cursor: pointer; color: var(--lf-text-muted); font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.lf-daterange-month-nav button:hover { background: var(--lf-bg); color: var(--lf-text); }
.lf-daterange-month-nav button:disabled { opacity: .3; cursor: default; }
.lf-daterange-month-nav button:disabled:hover { background: none; }
.lf-daterange-month-label { font-size: 14px; font-weight: 700; }
.lf-daterange-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.lf-daterange-weekday { text-align: center; font-size: 11px; font-weight: 700; color: var(--lf-text-muted); padding-bottom: 6px; }
.lf-daterange-day-cell { position: relative; display: flex; align-items: center; justify-content: center; height: 34px; }
.lf-daterange-day-cell.in-range::before { content: ""; position: absolute; inset: 0 0 0 0; background: var(--lf-primary-light); }
.lf-daterange-day-cell.range-start::before { left: 50%; }
.lf-daterange-day-cell.range-end::before { right: 50%; }
.lf-daterange-day {
  position: relative; z-index: 1; width: 30px; height: 30px; border-radius: 50%; border: 1px solid transparent;
  background: none; font-size: 13px; color: var(--lf-text); cursor: pointer; font-family: inherit;
}
.lf-daterange-day:hover:not(:disabled) { border-color: var(--lf-primary); }
.lf-daterange-day.is-today { font-weight: 700; }
.lf-daterange-day.is-endpoint { background: var(--lf-primary); color: #fff; font-weight: 600; }
.lf-daterange-day:disabled { color: #ccc; cursor: default; }
.lf-daterange-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--lf-border); }

/* Ad Pixels & CAPI scope switcher (app/integrations.php) — jump between the
   agency-wide default and any brand's own pixels without a detour back
   through the Brands page each time. A flat pill per brand only works up
   to a handful of them — past that (an agency running 100+ client brands)
   it turns into an unscannable wall of buttons, so only "Agency default"
   (and the current brand, if any) render as pills; every other brand is
   reached through the search box instead, which stays exactly as usable
   at 5 brands or 500. */
.lf-scope-switcher { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lf-scope-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  color: var(--lf-text); background: var(--lf-surface); border: 1.5px solid var(--lf-border); border-radius: 8px;
  padding: 7px 14px; flex-shrink: 0;
}
.lf-scope-pill:hover { border-color: var(--lf-primary); color: var(--lf-primary); text-decoration: none; }
.lf-scope-pill.active { background: var(--lf-primary); border-color: var(--lf-primary); color: #fff; }

.lf-scope-brand-search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.lf-scope-brand-search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--lf-text-muted); font-size: 13px; pointer-events: none; }
.lf-scope-brand-search .lf-input { padding-left: 34px; }
.lf-scope-brand-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 10; max-height: 260px; overflow-y: auto;
  background: var(--lf-surface); border: 1px solid var(--lf-border); border-radius: var(--lf-radius); box-shadow: var(--lf-shadow-hover);
}
.lf-scope-brand-result { display: block; padding: 9px 14px; font-size: 13.5px; color: var(--lf-text); border-bottom: 1px solid var(--lf-border); }
.lf-scope-brand-result:last-child { border-bottom: 0; }
.lf-scope-brand-result:hover { background: var(--lf-primary-light); color: var(--lf-primary); text-decoration: none; }

/* The short, naturally-bounded "who's different from the default" list —
   scales fine even with a huge total brand count, since only ones with an
   actual override ever show up here. */
.lf-overridden-brand-row { display: flex; padding: 11px 0; border-bottom: 1px solid var(--lf-border); color: var(--lf-text); }
.lf-overridden-brand-row:last-child { border-bottom: 0; }
.lf-overridden-brand-row:hover { color: var(--lf-primary); text-decoration: none; }

/* ---------- Alerts ---------- */
.lf-alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.lf-alert-success { background: var(--lf-success-bg); color: var(--lf-success); }
.lf-alert-danger { background: var(--lf-danger-bg); color: var(--lf-danger); }
.lf-alert-info { background: var(--lf-info-bg); color: var(--lf-info); }
.lf-alert-warning { background: var(--lf-warning-bg); color: var(--lf-warning); }

/* ---------- Misc ---------- */
.lf-flex { display: flex; align-items: center; }
.lf-flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lf-gap-8 { gap: 8px; } .lf-gap-12 { gap: 12px; } .lf-gap-16 { gap: 16px; }
.lf-mt-16 { margin-top: 16px; } .lf-mb-16 { margin-bottom: 16px; }
.lf-muted { color: var(--lf-text-muted); }
.lf-text-sm { font-size: 13px; }
.lf-empty { text-align: center; padding: 40px 20px; color: var(--lf-text-muted); }
.lf-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--lf-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.lf-avatar-sm { width: 28px; height: 28px; font-size: 12px; }

/* ---------- Brands page ---------- */
.lf-brand-swatch { width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0; }
.lf-brand-color-dot { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(0,0,0,.08); display: inline-block; }

/* ---------- Lead detail page ---------- */
.lf-avatar-lg { width: 52px; height: 52px; font-size: 19px; }
.lf-lead-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.lf-lead-hero-info { flex: 1; min-width: 200px; }
.lf-lead-hero-info h2 { margin: 0 0 6px; font-size: 20px; }
.lf-lead-hero-contact { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--lf-text-muted); }
.lf-lead-hero-contact a { color: var(--lf-text); font-weight: 600; }
.lf-lead-hero-contact a:hover { color: var(--lf-primary); }
.lf-lead-status-select {
  width: auto; padding: 7px 30px 7px 14px; border-radius: 999px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; border: 1.5px solid transparent; cursor: pointer;
}
.lf-lead-notes { display: flex; flex-direction: column; gap: 14px; }
.lf-lead-note { display: flex; gap: 10px; }
.lf-lead-note > div { flex: 1; padding-bottom: 14px; border-bottom: 1px solid #f0f0f0; }
.lf-lead-note:last-child > div { border-bottom: 0; padding-bottom: 0; }
.lf-danger-zone {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 20px; border: 1px dashed var(--lf-danger); border-radius: var(--lf-radius-lg); background: var(--lf-danger-bg);
}

/* ---------- Builder tab section headers (Design/Settings/SEO/Custom HTML/Publish) ---------- */
.lf-section-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.lf-section-icon {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--lf-primary-light); color: var(--lf-primary); font-size: 15px;
}
.lf-section-title { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.lf-section-subtitle { font-size: 12.5px; color: var(--lf-text-muted); margin-top: 2px; }
.lf-subcard { background: #fafafa; border: 1px solid var(--lf-border); border-radius: var(--lf-radius); padding: 14px; margin-top: 14px; }
.lf-subcard-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--lf-text-muted); margin-bottom: 12px; }

/* ---------- New-form page: name/brand card ---------- */
/* The max-width belongs on the card itself, not just the fields row inside
   it — capping only the inner row left the outer .lf-card stretching to
   whatever the page's full content width happened to be (huge on a wide
   monitor), with the two fields sitting in the left third of it and a slab
   of empty white space filling the rest. Capping the card keeps it sized to
   what it actually contains. */
.lf-newform-top { max-width: 760px; }
/* Fixed (not sticky — see the HTML comment above this bar), always visible
   regardless of scroll position. Spans the content area only — left tracks
   the sidebar's actual current width via the same --lf-sidebar-w var
   .lf-main's own margin-left uses, so it never sits under or past the
   sidebar at any collapsed/expanded state; the mobile override below
   matches .lf-main's own max-width:900px override, where the sidebar goes
   off-canvas and stops reserving any space at all. */
.lf-newform-bottom-cta {
  position: fixed; left: var(--lf-sidebar-w); right: 0; bottom: 0; z-index: 20;
  flex-wrap: wrap; gap: 12px; margin: 0; border-radius: 0;
  border: 0; border-top: 1px solid var(--lf-border); box-shadow: 0 -6px 20px rgba(0,0,0,.08);
}
.lf-newform-bottom-spacer { height: 78px; }
@media (max-width: 900px) { .lf-newform-bottom-cta { left: 0; } }
@media (max-width: 560px) {
  .lf-newform-bottom-cta { flex-direction: column-reverse; align-items: stretch; text-align: center; padding: 12px 14px; }
  .lf-newform-bottom-cta .lf-btn { width: 100%; justify-content: center; }
  .lf-newform-bottom-spacer { height: 116px; }
}

/* ---------- New-form template picker ---------- */
.lf-template-category-heading {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em; color: var(--lf-text-muted);
  margin: 22px 0 10px; scroll-margin-top: calc(var(--lf-topbar-h) + 14px);
}
/* Jump chips — mainly for phones, where scrolling past a dozen-plus
   category headings to find one is a lot of thumb work. Wraps instead of
   horizontal-scrolling so every category stays reachable without a swipe
   gesture that isn't otherwise used anywhere else on this page. */
.lf-template-jumpbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.lf-template-jumpchip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600;
  color: var(--lf-text); background: var(--lf-surface); border: 1px solid var(--lf-border); border-radius: 999px;
  padding: 6px 12px; white-space: nowrap;
}
.lf-template-jumpchip:hover { border-color: var(--lf-primary); color: var(--lf-primary); text-decoration: none; }
.lf-template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; scroll-margin-top: calc(var(--lf-topbar-h) + 14px); }
@media (max-width: 900px) { .lf-template-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .lf-template-grid { grid-template-columns: 1fr; } }
.lf-template-card {
  position: relative; display: flex; flex-direction: column; align-items: stretch;
  background: var(--lf-surface); border: 1.5px solid var(--lf-border); border-radius: var(--lf-radius-lg);
  padding: 0; overflow: hidden; cursor: pointer; transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.lf-template-card:hover { border-color: #c7c7c7; box-shadow: var(--lf-shadow-hover); transform: translateY(-1px); }
/* The radio's own circle is redundant — selection already reads clearly
   from the card's border/glow below — so it's visually hidden rather than
   removed outright: it's still the real, keyboard-accessible control the
   label toggles, just with no on-card dot competing with the preview
   button for the same top-right corner. */
.lf-template-card input[type="radio"] {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.lf-template-card:has(input:checked) { border-color: var(--lf-primary); box-shadow: 0 0 0 2px var(--lf-primary); }
/* Icon-only "open full preview" — same top-right spot the radio dot used
   to sit in. Its own click stops propagation (see the onclick on the <a>
   itself) so opening the preview never also re-selects the card underneath. */
.lf-template-preview-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  background: rgba(255,255,255,.92); color: var(--lf-text-muted); box-shadow: 0 1px 4px rgba(0,0,0,.18);
  transition: background .12s ease, color .12s ease;
}
.lf-template-preview-btn:hover { background: #fff; color: var(--lf-primary); text-decoration: none; }

/* Live thumbnail — a real (scaled down, non-interactive) render of the
   template's first step, via app/forms/template-preview.php?thumb=1 in an
   iframe. A fixed larger "virtual viewport" is scaled down with a CSS
   transform so the crop always shows the top of the form (logo/title/first
   fields) rather than a same-size-but-squashed page. */
.lf-template-thumb {
  position: relative; height: 150px; overflow: hidden; background: #f3f4f6;
  border-bottom: 1px solid var(--lf-border); flex-shrink: 0;
}
.lf-template-thumb-frame {
  position: absolute; top: 0; left: 0; width: 640px; height: 480px;
  border: 0; transform: scale(var(--thumb-scale, .34)); transform-origin: top left;
  pointer-events: none; /* clicks pass through to the <label> underneath instead of landing inside the iframe's own document */
}
.lf-template-blank .lf-template-thumb { display: flex; align-items: center; justify-content: center; }
.lf-template-kind-badge {
  position: absolute; left: 10px; bottom: 10px; z-index: 2;
  display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700;
  color: #fff; background: rgba(17,24,39,.72); padding: 3px 8px; border-radius: 6px; backdrop-filter: blur(2px);
}
.lf-template-icon {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--lf-primary-light); color: var(--lf-primary); font-size: 19px;
}
.lf-template-blank .lf-template-icon { background: var(--lf-primary); color: #fff; }
.lf-template-body { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px 14px; }
.lf-template-preview-link {
  font-size: 12px; font-weight: 700; color: var(--lf-text-muted);
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px;
}
.lf-template-preview-link:hover { color: var(--lf-primary); text-decoration: none; }

/* ---------- Mobile card fallback for tables (optional; toggled via JS/class) ---------- */
@media (max-width: 640px) {
  .lf-hide-mobile { display: none; }
}

/* =====================================================================
   SweetAlert2 theming — assets/js/notify.js turns off Swal's own inline
   button styling and hands every popup .lf-btn / .lf-card-shaped classes
   instead, so a confirm dialog or a toast looks like part of Sutra (same
   font, radius, shadow, monochrome icon rings) rather than a generic,
   unstyled library default.
   ===================================================================== */
.swal2-popup.lf-swal-popup {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  border-radius: var(--lf-radius-lg);
  box-shadow: var(--lf-shadow-hover);
  border: 1px solid var(--lf-border);
  padding: 28px 26px 24px;
}
.lf-swal-title { font-size: 19px !important; font-weight: 800 !important; color: var(--lf-text) !important; letter-spacing: -.01em; padding: 0 0 4px !important; }
.lf-swal-text { font-size: 14px !important; color: var(--lf-text-muted) !important; }
.lf-swal-actions { gap: 10px; margin-top: 20px !important; }
.lf-swal-actions .lf-btn { min-width: 96px; }
.swal2-popup .swal2-close { color: var(--lf-text-muted); }
.swal2-popup .swal2-close:hover { color: var(--lf-text); background: none; }

/* Icon rings recolored to the app's own semantic tokens instead of
   SweetAlert2's default bright orange/red/green. */
.swal2-icon.swal2-warning { border-color: var(--lf-warning); color: var(--lf-warning); }
.swal2-icon.swal2-error { border-color: var(--lf-danger); }
.swal2-icon.swal2-error [class^='swal2-x-mark-line'] { background-color: var(--lf-danger); }
.swal2-icon.swal2-success { border-color: var(--lf-success); color: var(--lf-success); }
.swal2-icon.swal2-success [class^='swal2-success-line'] { background-color: var(--lf-success); }
.swal2-icon.swal2-success .swal2-success-ring { border-color: color-mix(in srgb, var(--lf-success) 30%, transparent); }
.swal2-icon.swal2-question { border-color: var(--lf-text); color: var(--lf-text); }
.swal2-icon.swal2-info { border-color: var(--lf-info); color: var(--lf-info); }

/* Toast — the same crisp card look as the rest of the app, not Swal's
   default plain white/gray strip. */
.swal2-popup.lf-swal-toast {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  border-radius: var(--lf-radius); box-shadow: var(--lf-shadow-hover); border: 1px solid var(--lf-border);
  padding: 10px 16px;
}
.lf-swal-toast .swal2-title { font-size: 13.5px; font-weight: 700; color: var(--lf-text); }
.lf-swal-toast .swal2-timer-progress-bar { background: var(--lf-primary); opacity: .18; }

/* =====================================================================
   Form builder
   ===================================================================== */
.lf-builder-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--lf-border); flex-wrap: wrap; }
.lf-tab-btn { background: none; border: 0; padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--lf-text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.lf-tab-btn.active { color: var(--lf-primary); border-bottom-color: var(--lf-primary); }
.lf-tab-btn:hover:not(.active) { color: var(--lf-text); }

/* Build tab: palette | field editor | live preview. Each pane manages its
   own scroll so a long field list never drags the palette/preview out of
   view — this is the main fix for "hard to see everything at once". */
.lf-builder-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.lf-builder-grid.lf-design-grid { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 1200px) { .lf-builder-grid { grid-template-columns: 190px minmax(0, 1fr); } .lf-builder-grid.lf-design-grid { grid-template-columns: 1fr; } .lf-builder-preview { display: none; } }
@media (max-width: 820px) { .lf-builder-grid { grid-template-columns: 1fr; } }

.lf-builder-pane { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }

.lf-palette-heading { font-size: 13px; font-weight: 800; margin: 0 0 10px; color: var(--lf-text); }
.lf-palette-list { display: flex; flex-direction: column; gap: 4px; }
.lf-palette-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; width: 100%; text-align: left;
  border: 1px solid transparent; border-radius: 8px; background: none; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--lf-text);
}
.lf-palette-item:hover { border-color: var(--lf-border); background: var(--lf-primary-light); }
.lf-palette-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 7px; background: var(--lf-primary-light); color: var(--lf-primary); font-size: 14px;
}

@media (max-width: 820px) {
  /* Sticky + height-capped panes only make sense side-by-side with the
     canvas; stacked in one column on a phone they must go back to plain
     flow, or (real bug, seen on an actual phone) the palette's height cap
     falls apart against mobile browsers' dynamic 100vh and the whole list
     just floods the page above the actual field editor. */
  .lf-builder-pane { position: static; max-height: none; overflow-y: visible; }
  /* The 11-item palette turns into a horizontal scroll strip instead of a
     tall stack, so the actual field list is one short scroll away, not
     buried under a screen and a half of "Add a field" buttons. */
  .lf-palette-list { flex-direction: row; overflow-x: auto; gap: 8px; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
  .lf-palette-item { flex: 0 0 auto; white-space: nowrap; border: 1px solid var(--lf-border); border-radius: 999px; padding: 8px 14px; }
}

.lf-canvas-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.lf-step-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.lf-step-tab { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--lf-border); background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }
.lf-step-tab.active { background: var(--lf-primary); color: #fff; border-color: var(--lf-primary); }
.lf-step-add { border-style: dashed; color: var(--lf-primary); }
.lf-step-del { color: var(--lf-danger); border-color: var(--lf-danger-bg); background: var(--lf-danger-bg); }

.lf-field-list { display: flex; flex-direction: column; gap: 8px; }
.lf-field-card { border: 1px solid var(--lf-border); border-radius: 10px; background: #fff; overflow: hidden; }
.lf-field-card.dragging { opacity: .4; }
.lf-field-card.drag-over { border-color: var(--lf-primary); box-shadow: 0 0 0 1px var(--lf-primary); }
.lf-field-card-head { display: flex; align-items: center; gap: 10px; padding: 11px 12px; cursor: pointer; }
.lf-field-card-head:hover { background: var(--lf-primary-light); }
.lf-field-card.open .lf-field-card-head { border-bottom: 1px solid var(--lf-border); background: #fafafa; }
.lf-drag-handle { color: #b0b0b0; cursor: grab; flex-shrink: 0; display: flex; }
.lf-drag-handle:active { cursor: grabbing; }
.lf-field-type-badge {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex-shrink: 0;
  border-radius: 7px; background: var(--lf-primary-light); color: var(--lf-primary); font-size: 13px;
}
.lf-field-card-titles { flex: 1; min-width: 0; }
.lf-field-card-label { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lf-field-card-meta { font-size: 11.5px; color: var(--lf-text-muted); display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.lf-field-card-meta .req-dot { color: var(--lf-danger); }
.lf-field-card-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.lf-icon-btn { background: none; border: 1px solid transparent; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; font-size: 13px; color: var(--lf-text-muted); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.lf-icon-btn:hover { background: #fff; border-color: var(--lf-border); color: var(--lf-text); }
.lf-icon-btn.lf-icon-btn-danger:hover { color: var(--lf-danger); border-color: var(--lf-danger-bg); background: var(--lf-danger-bg); }
/* Same icon-only button, sized to match a normal .lf-btn/.lf-input row — for
   when it sits in a toolbar alongside full-size buttons/inputs instead of a
   compact row of card actions. */
.lf-icon-btn-lg { width: var(--lf-control-h); height: var(--lf-control-h); font-size: 16px; border-color: var(--lf-border); }
.lf-field-card-chevron { color: var(--lf-text-muted); transition: transform .15s ease; display: flex; }
.lf-field-card.open .lf-field-card-chevron { transform: rotate(90deg); }
.lf-field-card-body { padding: 14px 12px; }
.lf-checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin: 10px 0; }
.lf-conditional { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--lf-border); }

/* On/off toggle switch — for settings that flip a whole behaviour on or off
   (as opposed to a checkbox in a list of independent options), a switch
   reads faster than a checkbox at a glance. */
.lf-toggle-row { display: flex; align-items: flex-start; gap: 10px; margin: 10px 0; cursor: pointer; }
.lf-toggle { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; margin-top: 1px; }
.lf-toggle input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.lf-toggle-track { position: absolute; inset: 0; background: #d1d5db; border-radius: 999px; transition: background .15s ease; }
.lf-toggle-track .lf-toggle-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s ease; }
.lf-toggle input:checked + .lf-toggle-track { background: var(--lf-primary); }
.lf-toggle input:checked + .lf-toggle-track .lf-toggle-thumb { transform: translateX(16px); }
.lf-toggle input:focus-visible + .lf-toggle-track { box-shadow: 0 0 0 3px rgba(17,17,17,.12); }
.lf-toggle-label { font-size: 13px; font-weight: 600; color: var(--lf-text); line-height: 1.4; }

/* Live preview pane — reuses the real public-form.css classes so it looks
   exactly like the published form, just scaled to a narrower column. */
.lf-preview-heading { font-size: 13px; font-weight: 800; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.lf-preview-heading .lf-dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--lf-success); display: inline-block; }
.lf-preview-frame { background: #f2f2f2; border: 1px solid var(--lf-border); border-radius: 14px; padding: 22px 16px; }
.lf-preview-frame .lf-wrap { max-width: 100%; }
.lf-preview-frame .lf-card { padding: 20px; box-shadow: none; }
.lf-preview-frame .lf-field-conditional-tag { display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--lf-text-muted); background: var(--lf-primary-light); border-radius: 999px; padding: 2px 8px; margin-bottom: 6px; }
.lf-preview-empty { text-align: center; color: var(--lf-text-muted); font-size: 13px; padding: 40px 10px; }
