/**
 * LeadFlow Processing Framework — frontend styles.
 * Ops-console aesthetic. Dark is the signature; light is fully supported.
 * Everything is namespaced under #leadflow-app to stay isolated from themes.
 *
 * @package LeadFlow
 */

#leadflow-app, #leadflow-app * { box-sizing: border-box; }

#leadflow-app {
	/* ---- Dark theme tokens (default) ---- */
	--lf-bg: #0d1117;
	--lf-bg-2: #131a24;
	--lf-panel: #161e2b;
	--lf-panel-2: #1b2533;
	--lf-line: #243044;
	--lf-line-soft: #1c2737;
	--lf-text: #e6edf6;
	--lf-text-dim: #93a4bb;
	--lf-text-mute: #64748b;
	--lf-accent: #4f8cff;
	--lf-accent-ink: #0a1220;
	--lf-good: #22c55e;
	--lf-warn: #facc15;
	--lf-bad: #ef4444;
	--lf-radius: 12px;
	--lf-radius-sm: 8px;
	--lf-shadow: 0 10px 30px rgba(0,0,0,.45);
	--lf-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	--lf-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

	font-family: var(--lf-font);
	color: var(--lf-text);
	background:
		radial-gradient(1200px 500px at 80% -10%, rgba(79,140,255,.10), transparent 60%),
		var(--lf-bg);
	border: 1px solid var(--lf-line);
	border-radius: 16px;
	overflow: hidden;
	min-height: 640px;
	display: flex;
	flex-direction: column;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}

#leadflow-app.leadflow--light {
	--lf-bg: #f4f6fb;
	--lf-bg-2: #eef1f7;
	--lf-panel: #ffffff;
	--lf-panel-2: #f7f9fc;
	--lf-line: #e1e7f0;
	--lf-line-soft: #edf1f7;
	--lf-text: #16202e;
	--lf-text-dim: #56657b;
	--lf-text-mute: #8a99ad;
	--lf-accent: #2f6bff;
	--lf-accent-ink: #ffffff;
	--lf-shadow: 0 10px 30px rgba(20,40,80,.12);
	background:
		radial-gradient(1200px 500px at 80% -10%, rgba(47,107,255,.08), transparent 60%),
		var(--lf-bg);
}

#leadflow-app svg { width: 18px; height: 18px; display: block; }

/* ---------------------------------------------------------------- Header */

.lf-header {
	display: flex; align-items: center; gap: 12px;
	padding: 14px 18px;
	border-bottom: 1px solid var(--lf-line);
	background: linear-gradient( to bottom, var(--lf-panel), transparent );
}
.lf-brand { display: flex; align-items: baseline; gap: 8px; }
.lf-brand__mark {
	width: 30px; height: 30px; border-radius: 9px;
	display: grid; place-items: center;
	background: linear-gradient( 135deg, var(--lf-accent), #7c4dff );
	color: #fff; align-self: center;
	box-shadow: 0 4px 14px rgba(79,140,255,.4);
}
.lf-brand__mark svg { width: 17px; height: 17px; }
.lf-brand__name { font-weight: 800; letter-spacing: -.02em; font-size: 18px; }
.lf-brand__sub { font-size: 11px; color: var(--lf-text-mute); text-transform: uppercase; letter-spacing: .14em; }
.lf-header__spacer { flex: 1; }

.lf-pill {
	font-size: 12px; padding: 5px 11px; border-radius: 999px;
	border: 1px solid var(--lf-line); color: var(--lf-text-dim);
	background: var(--lf-panel-2); white-space: nowrap;
}
.lf-pill--ghost { background: transparent; }

.lf-icon-btn {
	display: grid; place-items: center;
	width: 36px; height: 36px; border-radius: 9px;
	background: var(--lf-panel-2); border: 1px solid var(--lf-line);
	color: var(--lf-text-dim); cursor: pointer; transition: .15s;
}
.lf-icon-btn:hover { color: var(--lf-text); border-color: var(--lf-accent); }
.lf-icon-btn--sm { width: 28px; height: 28px; }
.lf-theme-dot {
	width: 15px; height: 15px; border-radius: 50%;
	background: conic-gradient( var(--lf-warn), var(--lf-accent), #7c4dff, var(--lf-warn) );
}

/* ---------------------------------------------------------------- Stage layout */

.lf-stage { display: flex; flex: 1; min-height: 0; }

.lf-rail {
	width: 312px; flex: none;
	border-right: 1px solid var(--lf-line);
	background: var(--lf-bg-2);
	display: flex; flex-direction: column;
	padding: 16px; gap: 16px; overflow-y: auto;
}
.lf-rail__sec { display: flex; flex-direction: column; gap: 10px; }
.lf-rail__sec--grow { flex: 1; min-height: 0; }
.lf-rail__label {
	font-size: 11px; text-transform: uppercase; letter-spacing: .14em;
	color: var(--lf-text-mute); font-weight: 700;
}

/* ---- Dropzone ---- */
.lf-drop {
	position: relative; border: 1.5px dashed var(--lf-line);
	border-radius: var(--lf-radius); padding: 22px 16px; text-align: center;
	cursor: pointer; transition: .18s; background: var(--lf-panel);
}
.lf-drop:hover, .lf-drop--over {
	border-color: var(--lf-accent);
	background: color-mix( in srgb, var(--lf-accent) 8%, var(--lf-panel) );
}
.lf-drop--busy { opacity: .6; pointer-events: none; }
.lf-drop__icon { color: var(--lf-accent); display: grid; place-items: center; margin-bottom: 8px; }
.lf-drop__icon svg { width: 26px; height: 26px; }
.lf-drop__title { font-weight: 700; font-size: 14px; }
.lf-drop__hint { font-size: 12px; color: var(--lf-text-mute); margin-top: 3px; }
.lf-drop__input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---- Module palette ---- */
.lf-palette { display: flex; flex-direction: column; gap: 7px; }
.lf-palette__empty, .lf-pipeline__empty {
	font-size: 13px; color: var(--lf-text-mute); padding: 10px;
	border: 1px dashed var(--lf-line); border-radius: var(--lf-radius-sm); text-align: center;
}
.lf-modcard {
	--accent: var(--lf-accent);
	display: flex; align-items: center; gap: 10px; width: 100%;
	padding: 9px 11px; border-radius: var(--lf-radius-sm);
	background: var(--lf-panel); border: 1px solid var(--lf-line);
	color: var(--lf-text); cursor: pointer; text-align: left; transition: .15s;
}
.lf-modcard:hover { border-color: var(--accent); transform: translateX(2px); }
.lf-modcard__icon {
	width: 30px; height: 30px; flex: none; border-radius: 8px;
	display: grid; place-items: center; color: var(--accent);
	background: color-mix( in srgb, var(--accent) 14%, transparent );
}
.lf-modcard__body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.lf-modcard__name { font-weight: 650; font-size: 13px; }
.lf-modcard__type { font-size: 11px; color: var(--lf-text-mute); text-transform: capitalize; }
.lf-modcard__add { color: var(--lf-text-mute); }
.lf-modcard:hover .lf-modcard__add { color: var(--accent); }

/* ---- Pipeline ---- */
.lf-pipeline { display: flex; flex-direction: column; gap: 9px; overflow-y: auto; }
.lf-step {
	--accent: var(--lf-accent);
	border: 1px solid var(--lf-line); border-radius: var(--lf-radius-sm);
	background: var(--lf-panel); overflow: hidden;
	border-left: 3px solid var(--accent);
}
.lf-step__head { display: flex; align-items: center; gap: 8px; padding: 9px 11px; }
.lf-step__num {
	width: 20px; height: 20px; flex: none; border-radius: 6px; font-size: 11px; font-weight: 700;
	display: grid; place-items: center; background: var(--accent); color: #fff;
}
.lf-step__icon { color: var(--accent); }
.lf-step__name { font-weight: 650; font-size: 13px; flex: 1; }
.lf-step__spacer { flex: 1; }
.lf-step__btn {
	width: 24px; height: 24px; border-radius: 6px; border: none; cursor: pointer;
	background: transparent; color: var(--lf-text-mute); font-size: 13px;
	display: grid; place-items: center; transition: .15s;
}
.lf-step__btn:hover { background: var(--lf-panel-2); color: var(--lf-text); }
.lf-step__btn--del:hover { color: var(--lf-bad); }
.lf-step__btn svg { width: 14px; height: 14px; }
.lf-step__body { padding: 4px 11px 12px; display: flex; flex-direction: column; gap: 10px; }
.lf-step__note { font-size: 12px; color: var(--lf-text-mute); font-style: italic; }

/* ---- Fields ---- */
.lf-field { display: flex; flex-direction: column; gap: 5px; }
.lf-field__label { font-size: 12px; font-weight: 600; color: var(--lf-text-dim); }
.lf-field__help { font-size: 11px; color: var(--lf-text-mute); }
.lf-input {
	width: 100%; padding: 8px 10px; font-size: 13px; font-family: inherit;
	border-radius: var(--lf-radius-sm); border: 1px solid var(--lf-line);
	background: var(--lf-panel-2); color: var(--lf-text); transition: .15s;
}
.lf-input:focus { outline: none; border-color: var(--lf-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lf-accent) 22%, transparent); }
.lf-input--color { height: 38px; padding: 4px; cursor: pointer; }
select.lf-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2393a4bb' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

.lf-switch { display: inline-flex; cursor: pointer; }
.lf-switch input { position: absolute; opacity: 0; }
.lf-switch__track {
	width: 40px; height: 22px; border-radius: 999px; background: var(--lf-line);
	position: relative; transition: .18s;
}
.lf-switch__track::after {
	content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
	border-radius: 50%; background: #fff; transition: .18s;
}
.lf-switch input:checked + .lf-switch__track { background: var(--lf-accent); }
.lf-switch input:checked + .lf-switch__track::after { transform: translateX(18px); }

/* ---- Buttons ---- */
.lf-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 7px;
	padding: 9px 14px; font-size: 13px; font-weight: 650; font-family: inherit;
	border-radius: var(--lf-radius-sm); border: 1px solid var(--lf-line);
	background: var(--lf-panel-2); color: var(--lf-text); cursor: pointer; transition: .15s;
}
.lf-btn svg { width: 16px; height: 16px; }
.lf-btn:hover { border-color: var(--lf-accent); }
.lf-btn--primary {
	background: linear-gradient( 135deg, var(--lf-accent), #7c4dff );
	color: #fff; border-color: transparent;
	box-shadow: 0 4px 14px color-mix(in srgb, var(--lf-accent) 40%, transparent);
}
.lf-btn--primary:hover { filter: brightness(1.08); }
.lf-btn--ghost { background: transparent; }
.lf-btn--block { width: 100%; }
.lf-btn:disabled { opacity: .45; cursor: not-allowed; }
.lf-btn.is-busy { position: relative; color: transparent; }
.lf-btn.is-busy::after {
	content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
	border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: lf-spin .7s linear infinite;
}

/* ---------------------------------------------------------------- Main */

.lf-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--lf-bg); }

.lf-toolbar {
	display: flex; align-items: center; gap: 10px; padding: 12px 16px;
	border-bottom: 1px solid var(--lf-line); flex-wrap: wrap;
}
.lf-toolbar__spacer { flex: 1; }
.lf-search { position: relative; display: flex; align-items: center; min-width: 200px; }
.lf-search__icon { position: absolute; left: 10px; color: var(--lf-text-mute); pointer-events: none; }
.lf-search__icon svg { width: 15px; height: 15px; }
.lf-search__input {
	padding: 8px 12px 8px 32px; font-size: 13px; font-family: inherit; width: 240px;
	border-radius: 999px; border: 1px solid var(--lf-line);
	background: var(--lf-panel-2); color: var(--lf-text);
}
.lf-search__input:focus { outline: none; border-color: var(--lf-accent); }

.lf-hlgroup { display: flex; align-items: center; gap: 6px; }
.lf-hlgroup__label { font-size: 12px; color: var(--lf-text-mute); margin-right: 2px; }
.lf-swatch {
	width: 22px; height: 22px; border-radius: 6px; cursor: pointer;
	border: 2px solid color-mix(in srgb, var(--sw) 50%, var(--lf-line));
	background: var(--sw); transition: .15s;
}
.lf-swatch:hover { transform: scale(1.12); }

.lf-selinfo { font-size: 12px; color: var(--lf-accent); font-weight: 600; }

/* ---------------------------------------------------------------- Grid */

.lf-gridwrap { flex: 1; min-height: 0; overflow: hidden; display: flex; }
.lf-grid__scroll { flex: 1; overflow: auto; }

.lf-grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.lf-grid thead th {
	position: sticky; top: 0; z-index: 2;
	background: var(--lf-panel); color: var(--lf-text-dim);
	text-align: left; font-weight: 650; white-space: nowrap;
	padding: 10px 12px; border-bottom: 1px solid var(--lf-line);
	cursor: pointer; user-select: none;
}
.lf-grid__th { transition: color .15s; }
.lf-grid__th:hover { color: var(--lf-text); }
.lf-grid__th.is-sorted { color: var(--lf-accent); }
.lf-grid__sortarrow { font-size: 10px; color: var(--lf-accent); }
.lf-grid__sel { width: 40px; text-align: center !important; padding: 0 8px !important; }
.lf-grid thead .lf-grid__sel { position: sticky; left: 0; z-index: 3; }
.lf-grid tbody .lf-grid__sel { position: sticky; left: 0; z-index: 1; background: inherit; }

.lf-row td {
	padding: 9px 12px; border-bottom: 1px solid var(--lf-line-soft);
	max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
	background: var(--lf-bg);
}
.lf-row:hover td { background: var(--lf-panel); }
.lf-row--yellow td { background: color-mix(in srgb, var(--lf-warn) 16%, var(--lf-bg)); }
.lf-row--green td { background: color-mix(in srgb, var(--lf-good) 16%, var(--lf-bg)); }
.lf-row--red td { background: color-mix(in srgb, var(--lf-bad) 16%, var(--lf-bg)); }
.lf-row--yellow:hover td { background: color-mix(in srgb, var(--lf-warn) 24%, var(--lf-bg)); }
.lf-row--green:hover td { background: color-mix(in srgb, var(--lf-good) 24%, var(--lf-bg)); }
.lf-row--red:hover td { background: color-mix(in srgb, var(--lf-bad) 24%, var(--lf-bg)); }

.lf-check { width: 16px; height: 16px; accent-color: var(--lf-accent); cursor: pointer; }

/* ---- Empty / loading ---- */
.lf-empty, .lf-loading {
	flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
	gap: 10px; color: var(--lf-text-mute); text-align: center; padding: 40px;
}
.lf-empty__icon { color: var(--lf-line); }
.lf-empty__icon svg { width: 48px; height: 48px; }
.lf-empty__title { font-weight: 700; font-size: 16px; color: var(--lf-text-dim); }
.lf-empty__hint { font-size: 13px; }
.lf-spinner {
	width: 32px; height: 32px; border-radius: 50%;
	border: 3px solid var(--lf-line); border-top-color: var(--lf-accent); animation: lf-spin .8s linear infinite;
}
@keyframes lf-spin { to { transform: rotate(360deg); } }

/* ---- Artifacts ---- */
.lf-artifacts {
	border-top: 1px solid var(--lf-line); padding: 12px 16px;
	display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--lf-bg-2);
}
.lf-artifacts__label { font-size: 12px; color: var(--lf-text-mute); font-weight: 600; }
.lf-artifacts__item {
	display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
	padding: 6px 11px; border-radius: 999px; text-decoration: none;
	background: var(--lf-panel); color: var(--lf-text); border: 1px solid var(--lf-line);
}
.lf-artifacts__item:hover { border-color: var(--lf-accent); color: var(--lf-accent); }
.lf-artifacts__item svg { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- Footer / pager */

.lf-foot {
	display: flex; align-items: center; gap: 12px; padding: 10px 16px;
	border-top: 1px solid var(--lf-line); background: var(--lf-bg-2);
}
.lf-foot__spacer { flex: 1; }
.lf-foot__stat { font-size: 12px; color: var(--lf-text-mute); }
.lf-pager { display: flex; align-items: center; gap: 4px; }
.lf-page {
	min-width: 30px; height: 30px; padding: 0 8px; border-radius: 7px; cursor: pointer;
	background: var(--lf-panel); border: 1px solid var(--lf-line); color: var(--lf-text-dim);
	font-size: 12px; font-family: inherit; transition: .15s;
}
.lf-page:hover:not(:disabled) { border-color: var(--lf-accent); color: var(--lf-text); }
.lf-page.is-active { background: var(--lf-accent); color: #fff; border-color: transparent; }
.lf-page:disabled { opacity: .4; cursor: not-allowed; }
.lf-page__gap { color: var(--lf-text-mute); padding: 0 2px; }

/* ---------------------------------------------------------------- Recent */

.lf-recent { padding: 14px 18px; border-top: 1px solid var(--lf-line); background: var(--lf-bg-2); }
.lf-recent:empty { display: none; }
.lf-recent__head { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--lf-text-mute); font-weight: 700; margin-bottom: 9px; }
.lf-recent__list { display: flex; gap: 8px; flex-wrap: wrap; }
.lf-recent__item {
	display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
	padding: 8px 13px; border-radius: var(--lf-radius-sm);
	background: var(--lf-panel); border: 1px solid var(--lf-line); cursor: pointer; transition: .15s;
}
.lf-recent__item:hover { border-color: var(--lf-accent); }
.lf-recent__name { font-size: 13px; font-weight: 600; color: var(--lf-text); }
.lf-recent__meta { font-size: 11px; color: var(--lf-text-mute); }

/* ---------------------------------------------------------------- Modal */

.lf-modal { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center;
	background: rgba(5,8,14,.6); backdrop-filter: blur(3px); padding: 20px; }
.lf-modal__panel {
	width: 100%; max-width: 440px; background: var(--lf-panel);
	border: 1px solid var(--lf-line); border-radius: var(--lf-radius); box-shadow: var(--lf-shadow); overflow: hidden;
}
.lf-modal__head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--lf-line); font-weight: 700; }
.lf-modal__body { padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.lf-modal__field { display: flex; flex-direction: column; gap: 8px; }
.lf-modal__label { font-size: 12px; font-weight: 600; color: var(--lf-text-dim); }
.lf-modal__foot { padding: 15px 18px; border-top: 1px solid var(--lf-line); display: flex; justify-content: flex-end; }
.lf-choice { display: flex; gap: 7px; flex-wrap: wrap; }
.lf-choice__opt {
	padding: 8px 13px; font-size: 13px; border-radius: 999px; cursor: pointer; font-family: inherit;
	background: var(--lf-panel-2); border: 1px solid var(--lf-line); color: var(--lf-text-dim); transition: .15s;
}
.lf-choice__opt:hover { color: var(--lf-text); }
.lf-choice__opt.is-on { background: var(--lf-accent); color: #fff; border-color: transparent; }

/* ---------------------------------------------------------------- Column menu */

.lf-menu {
	position: absolute; z-index: 40; min-width: 180px; max-height: 280px; overflow-y: auto;
	background: var(--lf-panel); border: 1px solid var(--lf-line); border-radius: var(--lf-radius-sm);
	box-shadow: var(--lf-shadow); padding: 6px;
}
.lf-menu__item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.lf-menu__item:hover { background: var(--lf-panel-2); }

/* ---------------------------------------------------------------- Toasts */

.lf-toasts { position: absolute; bottom: 18px; right: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.lf-toast {
	padding: 11px 15px; border-radius: var(--lf-radius-sm); font-size: 13px; font-weight: 550;
	background: var(--lf-panel); border: 1px solid var(--lf-line); color: var(--lf-text);
	box-shadow: var(--lf-shadow); opacity: 0; transform: translateY(8px); transition: .3s;
	border-left: 3px solid var(--lf-accent); max-width: 320px;
}
.lf-toast--in { opacity: 1; transform: translateY(0); }
.lf-toast--success { border-left-color: var(--lf-good); }
.lf-toast--error { border-left-color: var(--lf-bad); }
.lf-toast--info { border-left-color: var(--lf-accent); }

/* ---------------------------------------------------------------- Locked */

.leadflow-locked {
	padding: 28px; border-radius: 14px; text-align: center;
	background: #161e2b; color: #93a4bb; border: 1px solid #243044; font-family: var(--lf-font, sans-serif);
}

/* ---------------------------------------------------------------- Responsive */

@media ( max-width: 880px ) {
	.lf-stage { flex-direction: column; }
	.lf-rail { width: auto; border-right: none; border-bottom: 1px solid var(--lf-line); max-height: 42vh; }
	.lf-main { min-height: 420px; }
	.lf-search__input { width: 160px; }
}
