/* =========================================================
   LeadForge — Components
   ---------------------------------------------------------
   All UI components. Load AFTER tokens.css and base.css.
   Naming: block (.btn) + modifier (.btn--primary).
   ========================================================= */

/* ============================== Buttons ============================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast), border-color var(--transition-fast),
              color var(--transition-fast), box-shadow var(--transition-fast);
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--color-focus-ring); }
.btn svg { width: 18px; height: 18px; }
.btn:disabled, .btn.is-disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

.btn--primary   { background: var(--color-primary); color: var(--color-primary-text); }
.btn--primary:hover  { background: var(--color-primary-hover); }
.btn--primary:active { background: var(--color-primary-active); }

.btn--secondary { background: var(--color-surface); color: var(--gray-700); border-color: var(--color-border-strong); }
.btn--secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn--ghost     { background: transparent; color: var(--color-text-secondary); }
.btn--ghost:hover { background: var(--gray-100); color: var(--color-text); }

.btn--subtle    { background: var(--color-primary-subtle); color: var(--color-on-subtle); }
.btn--subtle:hover { background: var(--brand-100); }

.btn--danger    { background: var(--color-danger); color: #fff; }
.btn--danger:hover { background: var(--red-700); }

.btn--sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn--sm svg { width: 16px; height: 16px; }
.btn--lg { height: 46px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn--icon { width: 40px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }
.btn--block { width: 100%; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: lf-spin 0.6s linear infinite;
}
@keyframes lf-spin { to { transform: rotate(360deg); } }

/* ============================== Forms ============================== */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.label { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--gray-700); }
.label .req { color: var(--color-danger); margin-left: 2px; }
.help { font-size: var(--text-sm); color: var(--color-text-tertiary); }
.field--error .help { color: var(--color-danger); }

.input, .textarea, .select {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--gray-400); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--gray-400); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-focus-ring);
}
.input:disabled, .textarea:disabled, .select:disabled {
  background: var(--gray-50); color: var(--color-text-tertiary); cursor: not-allowed;
}
.field--error .input, .field--error .textarea, .field--error .select { border-color: var(--color-danger); }
.field--error .input:focus { box-shadow: 0 0 0 4px rgba(240,68,56,0.14); }

.textarea { height: auto; min-height: 96px; padding: var(--space-3); line-height: var(--leading-snug); resize: vertical; }

.select {
  appearance: none;
  padding-right: var(--space-8);
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235d6675' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}


/* checkbox / radio */
.check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-base); user-select: none; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 1.5px solid var(--gray-400); border-radius: var(--radius-xs);
  background: var(--color-surface);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.check .box svg { width: 12px; height: 12px; color: #fff; opacity: 0; transform: scale(0.6); transition: opacity var(--transition-fast), transform var(--transition-fast); }
.check input:checked + .box { background: var(--color-primary); border-color: var(--color-primary); }
.check input:checked + .box svg { opacity: 1; transform: scale(1); }
.check input:focus-visible + .box { box-shadow: 0 0 0 4px var(--color-focus-ring); }

/* toggle switch (e.g. "No website only" filter) */
.toggle { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; user-select: none; font-size: var(--text-base); }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track {
  width: 40px; height: 22px; flex-shrink: 0; border-radius: var(--radius-full);
  background: var(--gray-300); position: relative; transition: background var(--transition-base);
}
.toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base);
}
.toggle input:checked + .track { background: var(--color-primary); }
.toggle input:checked + .track::after { transform: translateX(18px); }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 4px var(--color-focus-ring); }

/* ============================== Badges ============================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 var(--space-2);
  font-size: var(--text-xs); font-weight: var(--font-medium); line-height: 1;
  border-radius: var(--radius-full);
  background: var(--gray-100); color: var(--gray-700);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--new       { background: var(--amber-50); color: var(--amber-700); }
.badge--sold      { background: var(--green-50); color: var(--green-700); }
.badge--callback  { background: var(--brand-50); color: var(--brand-700); }
.badge--notnow    { background: var(--gray-100); color: var(--gray-600); }
.badge--success   { background: var(--green-50); color: var(--green-700); }
.badge--warning   { background: var(--amber-50); color: var(--amber-700); }
.badge--danger    { background: var(--red-50);   color: var(--red-700); }
.badge--info      { background: var(--blue-50);  color: var(--blue-700); }

/* collapsible card built on native <details> — keeps secondary sections tidy */
details.lf-collapse > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
details.lf-collapse > summary::-webkit-details-marker { display: none; }
details.lf-collapse > summary::marker { content: ""; }
details.lf-collapse .lf-collapse__chev { transition: transform .15s ease; color: var(--color-text-tertiary); flex: 0 0 auto; }
details.lf-collapse[open] > summary .lf-collapse__chev { transform: rotate(180deg); }

/* flexible snooze popover on the follow-ups queue */
.lf-snooze { position: relative; display: inline-block; }
.lf-snooze > summary { list-style: none; cursor: pointer; }
.lf-snooze > summary::-webkit-details-marker { display: none; }
.lf-snooze > summary::marker { content: ""; }
.lf-snooze__pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: 230px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px; box-shadow: 0 12px 32px rgba(24, 29, 38, .14); padding: 12px; }
.lf-snooze__lbl { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-tertiary); margin: 10px 0 4px; }
.lf-snooze__lbl:first-of-type { margin-top: 0; }

/* follow-up KPI header */
.lf-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.lf-kpi { text-align: center; padding: 6px 4px; }
.lf-kpi__num { font-size: 28px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.lf-kpi__lbl { font-size: 12px; color: var(--color-text-tertiary); margin-top: 5px; }
@media (max-width: 640px) { .lf-kpis { grid-template-columns: repeat(2, 1fr); } }

/* prominent "no website" filter toggle on find-leads */
.lf-nowebsite { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 14px; border: 1.5px solid var(--color-border); border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.lf-nowebsite:hover { border-color: var(--brand-400, #818cf8); }
.lf-nowebsite.is-on,
.lf-nowebsite:has(input:checked) { border-color: var(--brand-500, #6366f1); background: var(--brand-50, #eef2ff); }
.lf-nowebsite > input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--brand-600, #4f46e5); cursor: pointer; }
.lf-nowebsite__body { min-width: 0; }
.lf-nowebsite__title { display: block; font-weight: 600; font-size: 14px; }
.lf-nowebsite__desc { display: block; font-size: 12.5px; color: var(--color-text-tertiary); margin-top: 2px; }
.badge--brand     { background: var(--brand-50); color: var(--brand-700); }
.badge--outline   { background: transparent; box-shadow: inset 0 0 0 1px var(--color-border-strong); color: var(--gray-600); }

/* ============================== Cards ============================== */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); }
.card--pad { padding: var(--space-6); }
.card__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--color-border);
}
.card__title { font-size: var(--text-md); font-weight: var(--font-semibold); }
.card__subtitle { font-size: var(--text-sm); color: var(--color-text-tertiary); margin-top: 2px; }

/* ============================== Stat card ============================== */
.stat {
  display: flex; flex-direction: column; gap: var(--space-3);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-xl); padding: var(--space-5);
}
.stat__top { display: flex; align-items: center; justify-content: space-between; }
.stat__icon {
  width: 38px; height: 38px; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-primary-subtle); color: var(--color-primary);
}
.stat__icon svg { width: 20px; height: 20px; }
.stat__label { font-size: var(--text-sm); color: var(--color-text-tertiary); }
.stat__value { font-size: var(--text-3xl); font-weight: var(--font-semibold); letter-spacing: var(--tracking-tighter); line-height: 1.1; }
.stat__meta { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-tertiary); }

.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: var(--font-medium); }
.trend svg { width: 14px; height: 14px; }
.trend--up   { color: var(--color-success); }

/* ============================== Table ============================== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table thead th {
  text-align: left; padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs); font-weight: var(--font-medium);
  letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--color-text-tertiary); background: var(--gray-50);
  border-bottom: 1px solid var(--color-border); white-space: nowrap;
}
.table tbody td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--gray-50); }

/* ============================== Avatar ============================== */
.avatar {
  width: 36px; height: 36px; border-radius: var(--radius-full); flex-shrink: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-100); color: var(--brand-700);
  font-size: var(--text-sm); font-weight: var(--font-semibold);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 28px; height: 28px; font-size: var(--text-xs); }

/* ============================== Alerts ============================== */
.alert { display: flex; gap: var(--space-3); padding: var(--space-4); border: 1px solid transparent; border-radius: var(--radius-lg); font-size: var(--text-sm); }
.alert__icon { flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; }
.alert__title { font-weight: var(--font-semibold); margin-bottom: 2px; color: var(--color-text); }
.alert__body { color: var(--color-text-secondary); }
.alert--info    { background: var(--blue-50);  border-color: var(--blue-100);  }
.alert--info .alert__icon    { color: var(--blue-600); }
.alert--success { background: var(--green-50); border-color: var(--green-100); }
.alert--success .alert__icon { color: var(--green-600); }
.alert--warning { background: var(--amber-50); border-color: var(--amber-100); }
.alert--warning .alert__icon { color: var(--amber-600); }
.alert--danger  { background: var(--red-50);   border-color: var(--red-100);   }
.alert--danger .alert__icon  { color: var(--red-600); }

/* ============================== Progress (quota / usage) ============================== */
.progress { height: 8px; background: var(--gray-200); border-radius: var(--radius-full); overflow: hidden; }
.progress__bar { height: 100%; background: var(--color-primary); border-radius: var(--radius-full); transition: width var(--transition-base); }
.progress--warning .progress__bar { background: var(--color-warning); }
.progress--danger  .progress__bar { background: var(--color-danger); }

/* ============================== Score ring (AI website audit /100) ============================== */
.score {
  --val: 0; --ring: var(--color-primary);
  position: relative;
  width: 84px; height: 84px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: conic-gradient(var(--ring) calc(var(--val) * 1%), var(--gray-200) 0);
}
.score::before { content: ""; position: absolute; width: 64px; height: 64px; border-radius: 50%; background: var(--color-surface); }
.score__num { position: relative; font-size: var(--text-xl); font-weight: var(--font-semibold); color: var(--color-text); line-height: 1; }
.score__num span { font-size: var(--text-xs); color: var(--color-text-tertiary); font-weight: var(--font-medium); }
.score--good { --ring: var(--green-500); }
.score--mid  { --ring: var(--amber-500); }
.score--bad  { --ring: var(--red-500); }

/* ============================== Tabs ============================== */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-border); }
.tab { position: relative; padding: var(--space-3); font-size: var(--text-base); font-weight: var(--font-medium); color: var(--color-text-tertiary); cursor: pointer; transition: color var(--transition-fast); }
.tab:hover { color: var(--color-text-secondary); }
.tab.is-active { color: var(--color-primary); }
.tab.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--color-primary); border-radius: var(--radius-full); }

/* ============================== Dropdown menu ============================== */
.menu { min-width: 200px; padding: var(--space-2); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.menu__item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-base); color: var(--gray-700); cursor: pointer; transition: background var(--transition-fast); }
.menu__item:hover { background: var(--gray-100); }
.menu__item svg { width: 16px; height: 16px; color: var(--gray-500); }
.menu__sep { height: 1px; background: var(--color-border); margin: var(--space-2) 0; }

/* ============================== Empty state ============================== */
.empty { text-align: center; padding: var(--space-12) var(--space-6); }
.empty__icon { width: 48px; height: 48px; margin: 0 auto var(--space-4); border-radius: var(--radius-xl); background: var(--gray-100); color: var(--gray-400); display: grid; place-items: center; }
.empty__icon svg { width: 24px; height: 24px; }
.empty__title { font-size: var(--text-md); font-weight: var(--font-semibold); margin-bottom: var(--space-1); }
.empty__text { font-size: var(--text-sm); color: var(--color-text-tertiary); max-width: 360px; margin: 0 auto var(--space-5); }

/* ============================== App shell (sidebar + topbar + content) ============================== */
.app { min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: var(--z-sidebar);
  display: flex; flex-direction: column;
  background: var(--color-surface); border-right: 1px solid var(--color-border);
}
.sidebar__brand { display: flex; align-items: center; gap: var(--space-3); height: var(--topbar-h); padding: 0 var(--space-5); border-bottom: 1px solid var(--color-border); }
.brand-mark { width: 30px; height: 30px; border-radius: var(--radius-md); background: var(--color-primary); color: #fff; display: grid; place-items: center; font-weight: var(--font-bold); flex-shrink: 0; }
.brand-name { font-size: var(--text-md); font-weight: var(--font-semibold); letter-spacing: var(--tracking-tight); }

.sidebar__nav { flex: 1; padding: var(--space-4) var(--space-3); overflow-y: auto; }
.nav-label { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); font-weight: var(--font-medium); text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-tertiary); }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); margin-bottom: 2px; border-radius: var(--radius-md);
  font-size: var(--text-base); font-weight: var(--font-medium); color: var(--color-text-secondary);
  cursor: pointer; transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-item svg { width: 18px; height: 18px; color: var(--color-text-tertiary); transition: color var(--transition-fast); }
.nav-item:hover { background: var(--gray-100); color: var(--color-text); }
.nav-item:hover svg { color: var(--color-text-secondary); }
.nav-item.is-active { background: var(--color-primary-subtle); color: var(--color-on-subtle); }
.nav-item.is-active svg { color: var(--color-primary); }
.nav-item .nav-badge { margin-left: auto; }

.sidebar__foot { padding: var(--space-3); border-top: 1px solid var(--color-border); }
.user-chip { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2); border-radius: var(--radius-md); cursor: pointer; transition: background var(--transition-fast); }
.user-chip:hover { background: var(--gray-100); }
.user-chip__name { font-size: var(--text-sm); font-weight: var(--font-medium); line-height: 1.2; }
.user-chip__meta { font-size: var(--text-xs); color: var(--color-text-tertiary); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  height: var(--topbar-h); padding: 0 var(--space-6);
  background: rgba(255,255,255,0.82); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
}
.topbar__title { font-size: var(--text-lg); font-weight: var(--font-semibold); }
.topbar__greet { font-size: var(--text-sm); color: var(--color-text-tertiary); }
.topbar__actions { display: flex; align-items: center; gap: var(--space-3); }
.content { padding: var(--space-6); max-width: var(--content-max); width: 100%; }

.scrim { display: none; }

/* ============================== Responsive shell ============================== */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--transition-base); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; }
  .scrim { display: block; position: fixed; inset: 0; z-index: calc(var(--z-sidebar) - 1); background: rgba(16,24,40,0.4); opacity: 0; pointer-events: none; transition: opacity var(--transition-base); }
  .scrim.is-open { opacity: 1; pointer-events: auto; }
}
@media (max-width: 640px) {
  .content { padding: var(--space-4); }
  .topbar { padding: 0 var(--space-4); }
}

/* ============================== Site detail: header + tabs ============================== */
.site-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5); }
.site-head__main { display: flex; align-items: flex-start; gap: var(--space-3); }
.site-head__title-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.site-head__title { font-size: var(--text-xl); font-weight: var(--font-semibold); margin: 0; line-height: 1.2; }
.site-head__url { display: inline-block; margin-top: 4px; font-size: var(--text-sm); color: var(--color-primary); text-decoration: none; }
.site-head__url:hover { text-decoration: underline; }
.site-head__url.is-muted { color: var(--color-text-tertiary); }
.site-head__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.lf-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-5); overflow-x: auto; }
.lf-tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; padding: var(--space-3); font-size: var(--text-base); font-weight: var(--font-medium); color: var(--color-text-tertiary); cursor: pointer; white-space: nowrap; transition: color var(--transition-fast); }
.lf-tab:hover { color: var(--color-text-secondary); }
.lf-tab.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.lf-tab:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--color-focus-ring); border-radius: var(--radius-sm); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ============================== Metric strip (overview / review / log) ============================== */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
.metric { background: var(--color-surface-2); border-radius: var(--radius-lg); padding: var(--space-4); }
.metric__label { font-size: var(--text-sm); color: var(--color-text-tertiary); }
.metric__value { font-size: var(--text-2xl); font-weight: var(--font-semibold); line-height: 1.1; margin-top: 4px; }
.metric__value--success { color: var(--color-success); }
.metric__value--warning { color: var(--color-warning); }
.metric__value--danger { color: var(--color-danger); }

/* ============================== Studio (preview + AI chat) ============================== */
.studio { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
@media (max-width: 900px) { .studio { grid-template-columns: 1fr; } }

.chat { display: flex; flex-direction: column; }
.chat__thread { display: flex; flex-direction: column; gap: var(--space-3); }
.chat__msg { display: flex; gap: var(--space-2); max-width: 92%; }
.chat__msg--user { align-self: flex-end; }
.chat__msg--ai { align-self: flex-start; }
.chat__avatar { width: 26px; height: 26px; border-radius: var(--radius-full); background: var(--color-primary-subtle); color: var(--color-on-subtle); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; font-size: 13px; line-height: 0; }
.chat__bubble { padding: 9px 12px; border-radius: var(--radius-lg); font-size: var(--text-sm); line-height: 1.55; }
.chat__msg--ai .chat__bubble { background: var(--color-surface-2); color: var(--color-text); border-top-left-radius: var(--radius-xs); }
.chat__msg--user .chat__bubble { background: var(--color-primary-subtle); color: var(--color-on-subtle); border-top-right-radius: var(--radius-xs); }
.chat__applied { display: flex; align-items: center; gap: 5px; margin-top: 5px; font-size: var(--text-xs); color: var(--color-success); }

/* ============================== List rows (pages / settings / history) ============================== */
.list { display: flex; flex-direction: column; }

/* ============================== Site review: score hero + audit ============================== */
.score-panel { display: flex; align-items: center; gap: var(--space-5); padding: var(--space-5); background: var(--color-surface-2); border-radius: var(--radius-xl); }
.score-ring { position: relative; width: 108px; height: 108px; flex: 0 0 auto; }
.score-ring__num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.score-ring__num b { font-size: 28px; font-weight: var(--font-bold); }
.score-ring__num span { font-size: var(--text-xs); color: var(--color-text-tertiary); margin-top: 3px; }
.score-copy__verdict { font-size: var(--text-xl); font-weight: var(--font-semibold); }
.score-copy__sub { color: var(--color-text-secondary); margin-top: 6px; font-size: var(--text-sm); max-width: 54ch; line-height: 1.5; }
@media (max-width: 560px) { .score-panel { flex-direction: column; text-align: center; } }

.audit { display: flex; flex-direction: column; gap: var(--space-3); }
.audit-item { border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-4); }
.audit-item__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.audit-sub { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }

/* ============================== Generation log: table accent ============================== */

/* ============================== Code editor: IDE panes ============================== */
.editor { display: grid; grid-template-columns: 184px minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
@media (max-width: 1080px) { .editor { grid-template-columns: 184px minmax(0, 1fr); } .editor__preview { grid-column: 1 / -1; } }
@media (max-width: 680px) { .editor { grid-template-columns: 1fr; } }
.pane { border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); overflow: hidden; box-shadow: var(--shadow-xs); }
.pane__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--color-border); background: var(--color-surface-2); min-height: 48px; }
.pane__title { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--font-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filerail { padding: 8px; }
.filerail__label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-tertiary); margin: 4px 6px 10px; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-text); text-decoration: none; transition: background var(--transition-fast), color var(--transition-fast); }
.file-item:hover { background: var(--color-surface-2); }
.file-item.is-active { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-xs); }
.file-item__ico { opacity: .6; }
.chrome-dots { display: flex; gap: 5px; align-items: center; }
.chrome-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--color-border); display: block; }

/* ============================== LF redesign — dashboard + command palette ============================== */

/* KPI card with sparkline + trend */
.lf-kpi { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 12px 14px; }
.lf-kpi__label { font-size: var(--text-xs); color: var(--color-text-secondary); margin-bottom: 4px; }
.lf-kpi__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; }
.lf-kpi__value { font-size: var(--text-2xl); font-weight: var(--font-medium); line-height: 1.1; }
.lf-kpi__trend { font-size: var(--text-xs); display: inline-flex; align-items: center; gap: 3px; margin-top: 4px; }
.lf-kpi__trend svg { width: 13px; height: 13px; }
.lf-kpi__trend--up   { color: var(--color-success); }
.lf-kpi__trend--warn { color: var(--color-warning); }
.lf-kpi__trend--flat { color: var(--color-text-tertiary); }
.lf-spark { display: block; flex: 0 0 auto; }
.lf-spark polyline { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* Act now queue */
.lf-actnow__head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.lf-actnow__head svg { width: 16px; height: 16px; color: var(--color-primary); }
.lf-actnow__count { font-size: var(--text-xs); background: var(--color-primary-subtle); color: var(--color-on-subtle); border-radius: var(--radius-full); padding: 1px 8px; }
.lf-act { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--color-border); }
.lf-act:first-of-type { border-top: 0; }
.lf-act__ico { width: 32px; height: 32px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.lf-act__ico svg { width: 17px; height: 17px; }
.lf-act__body { min-width: 0; flex: 1; }
.lf-act__title { font-size: var(--text-sm); }
.lf-act__sub { font-size: var(--text-xs); color: var(--color-text-secondary); }
.lf-act__cta { margin-left: auto; flex: 0 0 auto; }
.lf-tint-warn    { background: var(--amber-50); color: var(--amber-600); }
.lf-tint-danger  { background: var(--red-50);   color: var(--red-600); }
.lf-tint-success { background: var(--green-50);  color: var(--green-600); }

/* Pipeline funnel */
.lf-funnel { display: flex; align-items: flex-start; gap: 9px; }
.lf-funnel__stage { flex: 1; min-width: 0; }
.lf-funnel__n { font-size: var(--text-lg); font-weight: var(--font-medium); }
.lf-funnel__l { font-size: var(--text-xs); color: var(--color-text-secondary); }
.lf-funnel__bar { height: 4px; border-radius: var(--radius-full); background: var(--color-primary); margin-top: 5px; min-width: 3px; }
.lf-funnel__bar--won { background: var(--color-success); }

/* Command-palette pill (topbar) */
.lf-kpill { display: inline-flex; align-items: center; gap: 7px; font-size: var(--text-sm); color: var(--color-text-tertiary); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 6px 10px; background: var(--color-surface); cursor: pointer; }
.lf-kpill:hover { background: var(--color-surface-2); }
.lf-kpill svg { width: 15px; height: 15px; }
.lf-kpill kbd { font-family: var(--font-mono); font-size: 10px; border: 1px solid var(--color-border); border-radius: var(--radius-xs); padding: 0 4px; color: var(--color-text-tertiary); }

/* Command-palette overlay */
.lf-cmdk { position: fixed; inset: 0; z-index: var(--z-modal); display: none; align-items: flex-start; justify-content: center; background: rgba(16,24,40,.4); padding: 12vh 16px 16px; }
.lf-cmdk.is-open { display: flex; }
.lf-cmdk__box { width: 100%; max-width: 480px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); overflow: hidden; }
.lf-cmdk__in { display: flex; align-items: center; gap: 9px; padding: 12px 14px; border-bottom: 1px solid var(--color-border); }
.lf-cmdk__in svg { width: 16px; height: 16px; color: var(--color-text-tertiary); flex: 0 0 auto; }
.lf-cmdk__in input { flex: 1; border: 0; outline: 0; background: transparent; font-size: var(--text-md); color: var(--color-text); font-family: inherit; }
.lf-cmdk__body { max-height: 320px; overflow-y: auto; padding: 6px; }
.lf-cmdk__grouplabel { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--color-text-tertiary); padding: 8px 8px 4px; }
.lf-cmdk__item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-md); cursor: pointer; font-size: var(--text-sm); }
.lf-cmdk__item svg { width: 16px; height: 16px; color: var(--color-text-secondary); flex: 0 0 auto; }
.lf-cmdk__item:hover, .lf-cmdk__item.is-sel { background: var(--color-primary-subtle); }
.lf-cmdk__item.is-sel svg { color: var(--color-primary); }
.lf-cmdk__hint { margin-left: auto; font-size: 10px; color: var(--color-text-tertiary); }
.lf-cmdk__empty { padding: 22px; text-align: center; font-size: var(--text-sm); color: var(--color-text-tertiary); }

/* ============================== LF redesign — skeleton loading states ============================== */
.lf-skel { position: relative; overflow: hidden; background: var(--color-surface-2); border-radius: var(--radius-sm); }
.lf-skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent); animation: lf-shimmer 1.25s infinite; }
@keyframes lf-shimmer { 100% { transform: translateX(100%); } }
.lf-skel-line { height: 12px; }
.lf-skel-row { display: flex; gap: 14px; align-items: center; padding: 13px 0; border-top: 1px solid var(--color-border); }
.lf-skel-row:first-child { border-top: 0; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: lf-spin .6s linear infinite; }

/* ============================== LF redesign — overflow menu (Site Studio toolbar) ============================== */
.lf-menu { position: relative; display: inline-block; }
.lf-menu__btn[aria-expanded="true"] { background: var(--color-surface-2); }
.lf-menu__pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 194px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; display: none; }
.lf-menu.is-open .lf-menu__pop { display: block; }
.lf-menu__item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: var(--radius-md); font-size: var(--text-sm); color: var(--color-text); text-decoration: none; background: none; border: 0; text-align: left; cursor: pointer; font-family: inherit; line-height: 1.3; }
.lf-menu__item:hover { background: var(--color-surface-2); }
.lf-menu__item svg { width: 15px; height: 15px; color: var(--color-text-secondary); flex: 0 0 auto; }
.lf-menu__sep { height: 1px; background: var(--color-border); margin: 5px 6px; }

/* ============================== LF redesign — Find Leads facets + WhatsApp ============================== */
.lf-facets { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.lf-facets__label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-tertiary); font-weight: var(--font-semibold); margin-right: 2px; }
.lf-facet { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text-secondary); border-radius: var(--radius-full); padding: 5px 12px; cursor: pointer; user-select: none; }
.lf-facet:hover { background: var(--color-surface-2); }
.lf-facet.is-on { background: var(--color-primary-subtle); border-color: var(--color-primary); color: var(--color-on-subtle); }
.lf-facet__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .55; }
.lf-wa { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-sm); color: var(--green-600); text-decoration: none; white-space: nowrap; }
.lf-wa svg { width: 14px; height: 14px; }
.lf-wa:hover { text-decoration: underline; }

/* ============================== LF redesign — Templates gallery ============================== */
.lf-tplchips { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 16px; }
.lf-fchip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 6px 3px 10px; border-radius: 999px; background: var(--color-surface-2); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.lf-fchip strong { font-weight: 600; color: var(--color-text); }
.lf-fchip__x { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; color: var(--color-text-tertiary); text-decoration: none; font-size: 14px; line-height: 1; }
.lf-fchip__x:hover { background: var(--color-border); color: var(--color-text); }
.lf-tplcontrols { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
/* vertical (stacked) filter form — full-width controls, fills its sidebar */
/* top loading bar — shown while a long action (generate, benchmark, find leads) submits */
.lf-topbar { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--color-primary, #6366f1), #a855f7); z-index: 9999; opacity: 0; transition: width .2s ease, opacity .35s ease; box-shadow: 0 0 8px rgba(99,102,241,.55); pointer-events: none; }
.lf-topbar.is-active { opacity: 1; }
.lf-vfilter { display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: 100%; }
.lf-vfilter > .select, .lf-vfilter > .input, .lf-vfilter > div { width: 100%; }
.lf-vfilter .input { width: 100%; }
/* filters-left / results-right layout (stacks on narrow screens) */
.lf-filterlayout { display: flex; gap: 20px; align-items: flex-start; }
.lf-filterlayout__side { flex: 0 0 232px; position: sticky; top: 16px; }
.lf-filterlayout__main { flex: 1 1 auto; min-width: 0; }
@media (max-width: 820px) {
    .lf-filterlayout { flex-direction: column; }
    .lf-filterlayout__side { flex: 1 1 auto; width: 100%; position: static; }
}
.lf-tplthumb__ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--color-surface-2); color: var(--color-text-tertiary); font-size: 26px; font-weight: 700; letter-spacing: .04em; }
.lf-tplthumb__ph.is-hidden { display: none; }
.lf-tplsection { margin-bottom: 26px; }
.lf-tplsection__head { font-size: 14px; font-weight: 600; color: var(--color-text-secondary); margin: 0 0 12px; }
.lf-tplchip { font-size: var(--text-sm); border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text-secondary); border-radius: var(--radius-full); padding: 5px 13px; cursor: pointer; }
.lf-tplchip:hover { background: var(--color-surface-2); }
.lf-tplchip.is-on { background: var(--color-primary-subtle); border-color: var(--color-primary); color: var(--color-on-subtle); }
.lf-tplgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 16px; }
.lf-tplcard { border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; background: var(--color-surface); }
.lf-tplthumb { position: relative; height: 200px; overflow: hidden; background: #fff; border-bottom: 1px solid var(--color-border); }
.lf-tplthumb__frame { position: absolute; top: 0; left: 0; width: 1200px; height: 1600px; transform: scale(.2); transform-origin: top left; transition: transform 3.2s ease; pointer-events: none; will-change: transform; }
.lf-tplthumb__frame iframe { width: 1200px; height: 1600px; border: 0; background: #fff; display: block; }
.lf-tplthumb__ov { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; background: linear-gradient(to top, rgba(16,24,40,.74), rgba(16,24,40,0)); opacity: 0; transition: opacity .16s; }
.lf-tplcard:hover .lf-tplthumb__ov { opacity: 1; }

/* full-screen device-toggle preview modal */
.lf-tplmodal { position: fixed; inset: 0; z-index: 200; background: rgba(16,24,40,.62); display: flex; flex-direction: column; }
.lf-tplmodal__bar { display: flex; align-items: center; gap: 12px; padding: 11px 16px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); flex-wrap: wrap; }
.lf-tplmodal__devices { display: inline-flex; gap: 4px; background: var(--color-surface-2); border-radius: 8px; padding: 3px; }
.lf-tplmodal__devices button { border: 0; background: none; padding: 5px 13px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--color-text-secondary); }
.lf-tplmodal__devices button.is-on { background: var(--color-surface); color: var(--color-text); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.lf-tplmodal__stage { flex: 1; min-height: 0; overflow: auto; display: flex; justify-content: center; padding: 20px; }
.lf-tplmodal__frame { border: 0; background: #fff; box-shadow: 0 10px 44px rgba(0,0,0,.32); border-radius: 6px; height: 100%; transition: width .2s ease; }
.lf-tplmodal__frame.is-desktop { width: 100%; max-width: 1200px; }
.lf-tplmodal__frame.is-mobile { width: 390px; flex: 0 0 390px; }
.lf-tplmeta { padding: 11px 13px; display: flex; align-items: center; gap: 8px; }
.lf-tplmeta__name { font-size: var(--text-sm); font-weight: var(--font-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lf-tplmeta__sub { font-size: var(--text-xs); color: var(--color-text-tertiary); }

/* ============================== LF redesign — Settings section-nav ============================== */
.lf-settings { display: grid; grid-template-columns: 212px 1fr; gap: 22px; align-items: start; max-width: 920px; }
.lf-setnav { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 2px; }
.lf-setnav__search { width: 100%; margin-bottom: 8px; padding: 8px 11px; font-size: var(--text-sm); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text); font-family: inherit; }
.lf-setnav__item { display: flex; align-items: center; gap: 9px; text-align: left; width: 100%; padding: 8px 11px; border: 0; background: none; border-radius: var(--radius-md); font-size: var(--text-sm); color: var(--color-text-secondary); cursor: pointer; font-family: inherit; }
.lf-setnav__item:hover { background: var(--color-surface-2); }
.lf-setnav__item.is-active { background: var(--color-primary-subtle); color: var(--color-on-subtle); font-weight: var(--font-medium); }
.lf-setnav__item svg { width: 15px; height: 15px; flex: 0 0 auto; color: var(--color-text-tertiary); }
.lf-setnav__item.is-active svg { color: var(--color-primary); }
.lf-setpane { display: none; }
.lf-setpane.is-active { display: block; }
@media (max-width: 640px) { .lf-settings { grid-template-columns: 1fr; } .lf-setnav { position: static; flex-direction: row; flex-wrap: wrap; } .lf-setnav__search { flex: 1 0 100%; } }

/* ============================== LF redesign — mobile bottom nav + FAB + theme toggle ============================== */
.lf-botnav { display: none; }
.lf-fab { display: none; }
.lf-themetoggle { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text-secondary); cursor: pointer; }
.lf-themetoggle:hover { background: var(--color-surface-2); }
.lf-themetoggle svg { width: 16px; height: 16px; }
.lf-theme-sun { display: none; }
[data-theme="dark"] .lf-theme-sun { display: block; }
[data-theme="dark"] .lf-theme-moon { display: none; }

@media (max-width: 1024px) {
  .lf-botnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky);
    background: var(--color-surface); border-top: 1px solid var(--color-border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .lf-botnav__item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 0; font-size: 11px; color: var(--color-text-tertiary); text-decoration: none;
    background: none; border: 0; cursor: pointer; font-family: inherit;
  }
  .lf-botnav__item svg { width: 21px; height: 21px; }
  .lf-botnav__item.is-active { color: var(--color-primary); }
  .lf-fab {
    display: flex; align-items: center; justify-content: center;
    position: fixed; right: 18px; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); z-index: var(--z-sticky);
    width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--color-primary); color: #fff; box-shadow: var(--shadow-lg); text-decoration: none;
  }
  .lf-fab svg { width: 24px; height: 24px; }
  .content { padding-bottom: 80px; }
}
body.lf-navopen .lf-botnav, body.lf-navopen .lf-fab { display: none; }

/* ============================== LF redesign — settings toggle switches ============================== */
.lf-switchrow { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--color-border); }
.lf-switchrow:first-of-type { border-top: 0; }
.lf-switchrow__label { font-size: var(--text-sm); font-weight: var(--font-medium); }
.lf-switchrow__desc { font-size: var(--text-xs); color: var(--color-text-tertiary); margin-top: 2px; }
.lf-switch { position: relative; flex: 0 0 auto; width: 40px; height: 23px; display: inline-block; }
.lf-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.lf-switch__track { position: absolute; inset: 0; background: var(--color-border-strong); border-radius: 999px; transition: background .15s; }
.lf-switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow-sm); }
.lf-switch input:checked + .lf-switch__track { background: var(--color-primary); }
.lf-switch input:checked + .lf-switch__track::after { transform: translateX(17px); }

/* ============================== LF redesign — code editor device toggle ============================== */
.ce-dev { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 28px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text-tertiary); cursor: pointer; }
.ce-dev:first-of-type { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.ce-dev:last-of-type { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.ce-dev + .ce-dev { margin-left: -1px; }
.ce-dev.is-on { background: var(--color-surface-2); color: var(--color-text); }
.ce-dev svg { width: 15px; height: 15px; }

/* ============================== LF redesign — collapsible sidebar ============================== */
.lf-navtoggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-text-tertiary); cursor: pointer; flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.lf-navtoggle:hover { background: var(--gray-100); color: var(--color-text); }
.lf-navtoggle svg { width: 17px; height: 17px; }

.sidebar, .main { transition: width var(--transition-base), margin-left var(--transition-base); }

@media (min-width: 1025px) {
  .lf-nav-collapsed .sidebar { width: 74px; }
  .lf-nav-collapsed .main { margin-left: 74px; }
  .lf-nav-collapsed .brand-name,
  .lf-nav-collapsed .nav-item__label,
  .lf-nav-collapsed .nav-label,
  .lf-nav-collapsed .nav-item .nav-badge,
  .lf-nav-collapsed .user-chip__name,
  .lf-nav-collapsed .user-chip__meta { display: none; }
  .lf-nav-collapsed .sidebar__brand { justify-content: center; padding: 0; gap: 0; }
  .lf-nav-collapsed .sidebar__nav { padding-left: var(--space-2); padding-right: var(--space-2); }
  .lf-nav-collapsed .nav-item { justify-content: center; padding: 10px; }
  .lf-nav-collapsed .user-chip { justify-content: center; }
}
@media (max-width: 1024px) { .lf-navtoggle { display: none; } }

/* ============================== LF redesign — code editor polish ============================== */
:root { --ce-h: clamp(440px, calc(100vh - 250px), 780px); }
.ce-code, .ce-frame { height: var(--ce-h); }
.editor .CodeMirror { height: var(--ce-h); }
.chrome-dots i:nth-child(1) { background: #ff5f57; }
.chrome-dots i:nth-child(2) { background: #febc2e; }
.chrome-dots i:nth-child(3) { background: #28c840; }

/* ============================== LF redesign — collapsible editor panes ============================== */
.ce-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text-tertiary); cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
}
.ce-toggle:hover { background: var(--color-surface-2); color: var(--color-text); }
.ce-toggle.is-off { opacity: .45; }
.ce-toggle svg { width: 15px; height: 15px; }

@media (min-width: 1081px) {
  .editor.ce-hide-files { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .editor.ce-hide-files .filerail { display: none; }
  .editor.ce-hide-preview { grid-template-columns: 184px minmax(0,1fr); }
  .editor.ce-hide-preview .editor__preview { display: none; }
  .editor.ce-hide-files.ce-hide-preview { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 1080px) { .ce-toggle { display: none; } }

/* ============ ADMIN DASHBOARD (Phase 1) ============ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-4); }
.kpi { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); padding: var(--space-5); display: flex; flex-direction: column; gap: 10px; transition: border-color var(--transition-fast), box-shadow var(--transition-fast); }
.kpi:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-sm); }
.kpi__head { display: flex; align-items: center; justify-content: space-between; }
.kpi__icon { width: 38px; height: 38px; border-radius: var(--radius-lg); background: var(--brand-50); color: var(--brand-600); display: grid; place-items: center; flex-shrink: 0; }
.kpi__icon svg { width: 19px; height: 19px; }
.kpi__label { font-size: var(--text-sm); color: var(--color-text-secondary); font-weight: var(--font-medium); }
.kpi__value { font-size: var(--text-3xl); font-weight: var(--font-bold); letter-spacing: var(--tracking-tighter); line-height: 1; color: var(--color-text); }
.kpi__meta { font-size: var(--text-xs); color: var(--color-text-tertiary); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: var(--font-semibold); padding: 2px 8px; border-radius: var(--radius-full); }
.delta--up   { background: color-mix(in srgb, #16a34a 14%, transparent); color: #16a34a; }
.delta--down { background: color-mix(in srgb, #dc2626 14%, transparent); color: #dc2626; }
.delta--flat { background: var(--gray-100); color: var(--color-text-tertiary); }
.delta svg { width: 12px; height: 12px; }

.dash-h { font-size: 13px; font-weight: var(--font-bold); text-transform: uppercase; letter-spacing: .06em; color: var(--gray-700); margin: var(--space-6) 0 var(--space-3); }

.qa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); }
.qa { display: flex; align-items: center; gap: 11px; padding: 14px 16px; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); color: var(--color-text); text-decoration: none; font-weight: var(--font-medium); font-size: var(--text-base); transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast); }
.qa:hover { border-color: var(--brand-300); background: var(--brand-50); transform: translateY(-1px); }
.qa svg { width: 18px; height: 18px; color: var(--brand-600); flex-shrink: 0; }

.alerts-panel { border: 1px solid color-mix(in srgb, #dc2626 40%, transparent); background: color-mix(in srgb, #dc2626 7%, var(--color-surface)); border-radius: var(--radius-xl); padding: var(--space-4) var(--space-5); }
.alerts-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.alerts-panel__title { font-weight: var(--font-semibold); color: #b91c1c; display: flex; align-items: center; gap: 8px; }
.alerts-panel__row { font-size: var(--text-sm); color: var(--color-text-secondary); padding: 7px 0; border-top: 1px solid color-mix(in srgb, #dc2626 18%, transparent); }
.alerts-panel__row:first-of-type { border-top: 0; }
.alerts-panel__row .mono { font-size: 11px; opacity: .7; }

/* ============ ADMIN DASHBOARD (Phase 2: trend + funnel) ============ */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 172px; }
.chart__col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; }
.chart__barwrap { flex: 1; display: flex; align-items: flex-end; padding-top: 20px; }
.chart__bar { width: 100%; max-width: 30px; margin: 0 auto; background: var(--brand-100); border-radius: 5px 5px 0 0; position: relative; min-height: 3px; transition: background var(--transition-fast); }
.chart__bar:hover { background: var(--brand-500); }
.chart__bar b { position: absolute; top: -19px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: var(--font-semibold); color: var(--color-text); opacity: 0; transition: opacity var(--transition-fast); pointer-events: none; }
.chart__bar:hover b { opacity: 1; }
.chart__x { height: 20px; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--color-text-tertiary); white-space: nowrap; }

.funnel { display: flex; flex-direction: column; gap: 14px; }
.funnel__meta { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.funnel__name { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-text); }
.funnel__val { font-size: var(--text-sm); color: var(--color-text-secondary); }
.funnel__val strong { color: var(--brand-600); font-weight: var(--font-semibold); }
.funnel__track { height: 32px; border-radius: var(--radius-md); background: var(--gray-100); overflow: hidden; }
.funnel__fill { height: 100%; border-radius: var(--radius-md); display: flex; align-items: center; padding: 0 12px; font-size: 12px; font-weight: var(--font-semibold); color: #fff; background: var(--brand-600); min-width: 34px; transition: width var(--transition-base); }

/* ============ ADMIN DASHBOARD (Phase 3: health + activity) ============ */
.health { display: flex; flex-direction: column; }
.health__row { display: flex; align-items: center; gap: 12px; padding: 13px 2px; border-bottom: 1px solid var(--color-border); }
.health__row:last-child { border-bottom: 0; }
.health__dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.health__dot.ok   { background: #16a34a; box-shadow: 0 0 0 4px color-mix(in srgb, #16a34a 16%, transparent); }
.health__dot.warn { background: #d97706; box-shadow: 0 0 0 4px color-mix(in srgb, #d97706 16%, transparent); }
.health__dot.bad  { background: #dc2626; box-shadow: 0 0 0 4px color-mix(in srgb, #dc2626 16%, transparent); }
.health__name { font-size: var(--text-base); font-weight: var(--font-medium); }
.health__status { margin-left: auto; font-size: var(--text-sm); color: var(--color-text-secondary); }

.feed { display: flex; flex-direction: column; }
.feed__item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--color-border); }
.feed__item:last-child { border-bottom: 0; }
.feed__ic { width: 30px; height: 30px; border-radius: var(--radius-md); display: grid; place-items: center; flex-shrink: 0; }
.feed__ic svg { width: 15px; height: 15px; }
.feed__ic--lead    { background: var(--brand-50); color: var(--brand-600); }
.feed__ic--site    { background: color-mix(in srgb, #16a34a 12%, transparent); color: #16a34a; }
.feed__ic--account { background: color-mix(in srgb, #d97706 14%, transparent); color: #d97706; }
.feed__text { flex: 1; min-width: 0; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed__time { font-size: var(--text-xs); color: var(--color-text-tertiary); flex-shrink: 0; }

/* ============ Mobile: stack wide data tables into readable cards ============ */
@media (max-width: 640px) {
  .table-wrap { overflow-x: visible; }
  .table thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .table, .table tbody, .table tbody tr, .table tbody td { display: block; width: 100%; }
  .table tbody tr { border: 1px solid var(--color-border); border-radius: var(--radius-lg); margin-bottom: 12px; padding: 4px 0; background: var(--color-surface); }
  .table tbody tr:hover { background: var(--color-surface); }
  .table tbody td { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 14px; border: 0; border-bottom: 1px solid var(--color-border); text-align: right; }
  .table tbody tr td:last-child { border-bottom: 0; }
  .table tbody td::before { content: attr(data-label); font-weight: var(--font-semibold); color: var(--color-text-secondary); text-align: left; flex: 0 0 auto; }
  .table tbody td:empty { display: none; }
}

/* ============ Toasts (flash → non-blocking, auto-dismiss) ============ */
.lf-toasts { position: fixed; top: 16px; right: 16px; z-index: 1200; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, 92vw); }
.lf-toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-lg); background: var(--color-surface); border: 1px solid var(--color-border); box-shadow: var(--shadow-lg); font-size: 13.5px; animation: lfToastIn .25s ease; }
.lf-toast--success { border-left: 3px solid var(--color-success); }
.lf-toast--error { border-left: 3px solid var(--color-danger); }
.lf-toast__ico { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.lf-toast--success .lf-toast__ico { color: var(--color-success); }
.lf-toast--error .lf-toast__ico { color: var(--color-danger); }
.lf-toast__body { flex: 1; color: var(--color-text); line-height: 1.4; }
.lf-toast__x { background: none; border: 0; color: var(--color-text-tertiary); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; flex: 0 0 auto; }
.lf-toast__x:hover { color: var(--color-text); }
.lf-toast.is-out { animation: lfToastOut .25s ease forwards; }
@keyframes lfToastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes lfToastOut { to { opacity: 0; transform: translateX(16px); } }
@media (max-width: 640px) { .lf-toasts { top: auto; bottom: 78px; left: 12px; right: 12px; max-width: none; } }
